rdb

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2016 License: Apache-2.0, BSD-3-Clause, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockBasedTableOptions

type BlockBasedTableOptions struct {
	// contains filtered or unexported fields
}

BlockBasedTableOptions represents block-based table options.

func NewDefaultBlockBasedTableOptions

func NewDefaultBlockBasedTableOptions() *BlockBasedTableOptions

NewDefaultBlockBasedTableOptions creates a default BlockBasedTableOptions object.

func NewNativeBlockBasedTableOptions

func NewNativeBlockBasedTableOptions(c *C.rdb_block_based_table_options_t) *BlockBasedTableOptions

NewNativeBlockBasedTableOptions creates a BlockBasedTableOptions object.

func (*BlockBasedTableOptions) Destroy

func (opts *BlockBasedTableOptions) Destroy()

Destroy deallocates the BlockBasedTableOptions object.

func (*BlockBasedTableOptions) SetBlockCache

func (opts *BlockBasedTableOptions) SetBlockCache(cache *Cache)

SetBlockCache sets the control over blocks (user data is stored in a set of blocks, and a block is the unit of reading from disk).

If set, use the specified cache for blocks. If nil, rocksdb will auoptsmatically create and use an 8MB internal cache. Default: nil

func (*BlockBasedTableOptions) SetBlockCacheCompressed

func (opts *BlockBasedTableOptions) SetBlockCacheCompressed(cache *Cache)

SetBlockCacheCompressed sets the cache for compressed blocks. If nil, rocksdb will not use a compressed block cache. Default: nil

func (*BlockBasedTableOptions) SetBlockSize

func (opts *BlockBasedTableOptions) SetBlockSize(blockSize int)

SetBlockSize sets the approximate size of user data packed per block. Note that the block size specified here corresponds opts uncompressed data. The actual size of the unit read from disk may be smaller if compression is enabled. This parameter can be changed dynamically. Default: 4K

func (*BlockBasedTableOptions) SetFilterPolicy

func (opts *BlockBasedTableOptions) SetFilterPolicy(fp FilterPolicy)

SetFilterPolicy sets the filter policy opts reduce disk reads. Many applications will benefit from passing the result of NewBloomFilterPolicy() here. Default: nil

func (*BlockBasedTableOptions) SetNoBlockCache

func (opts *BlockBasedTableOptions) SetNoBlockCache(value bool)

SetNoBlockCache specify whether block cache should be used or not. Default: false

func (*BlockBasedTableOptions) SetWholeKeyFiltering

func (opts *BlockBasedTableOptions) SetWholeKeyFiltering(value bool)

SetWholeKeyFiltering specify if whole keys in the filter (not just prefixes) should be placed. This must generally be true for gets opts be efficient. Default: true

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a cache used to store data read from data in memory.

func NewLRUCache

func NewLRUCache(capacity int) *Cache

NewLRUCache creates a new LRU Cache object with the capacity given.

func NewNativeCache

func NewNativeCache(c *C.rdb_cache_t) *Cache

NewNativeCache creates a Cache object.

func (*Cache) Destroy

func (c *Cache) Destroy()

Destroy deallocates the Cache object.

type Checkpoint

type Checkpoint struct {
	// contains filtered or unexported fields
}

Checkpoint can be used to create openable snapshots.

func (*Checkpoint) Destroy

func (s *Checkpoint) Destroy()

Destroy removes the snapshot from the database's list of snapshots.

func (*Checkpoint) Save

func (s *Checkpoint) Save(checkpointDir string) error

Save builds openable snapshot of RocksDB on disk. CAUTION: checkpointDir should not already exist. If so, nothing will happen.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a reusable handle to a RocksDB database on disk, created by Open.

func OpenDb

func OpenDb(opts *Options, name string) (*DB, error)

OpenDb opens a database with the specified options.

func OpenDbForReadOnly

func OpenDbForReadOnly(opts *Options, name string, errorIfLogFileExist bool) (*DB, error)

OpenDbForReadOnly opens a database with the specified options for readonly usage.

func (*DB) Close

func (db *DB) Close()

Close closes the database.

func (*DB) Delete

func (db *DB) Delete(opts *WriteOptions, key []byte) error

Delete removes the data associated with the key from the database.

func (*DB) Get

func (db *DB) Get(opts *ReadOptions, key []byte) (*Slice, error)

Get returns the data associated with the key from the database. Remember to deallocate the returned Slice.

func (*DB) GetBytes

func (db *DB) GetBytes(opts *ReadOptions, key []byte) ([]byte, error)

GetBytes is like Get but returns a copy of the data.

func (*DB) GetProperty

func (db *DB) GetProperty(propName string) string

GetProperty returns the value of a database property.

func (*DB) GetStats

func (db *DB) GetStats() string

GetStats returns stats of our data store.

func (*DB) NewCheckpoint

func (db *DB) NewCheckpoint() (*Checkpoint, error)

NewCheckpoint creates a new snapshot of the database.

func (*DB) NewIterator

func (db *DB) NewIterator(opts *ReadOptions) *Iterator

NewIterator returns an Iterator over the the database that uses the ReadOptions given.

func (*DB) NewSnapshot

func (db *DB) NewSnapshot() *Snapshot

NewSnapshot creates a new snapshot of the database.

func (*DB) Put

func (db *DB) Put(opts *WriteOptions, key, value []byte) error

Put writes data associated with a key to the database.

func (*DB) Write

func (db *DB) Write(opts *WriteOptions, batch *WriteBatch) error

Write writes a WriteBatch to the database

type FilterPolicy

type FilterPolicy interface {
	// keys contains a list of keys (potentially with duplicates)
	// that are ordered according to the user supplied comparator.
	CreateFilter(keys [][]byte) []byte

	// "filter" contains the data appended by a preceding call to
	// CreateFilter(). This method must return true if
	// the key was in the list of keys passed to CreateFilter().
	// This method may return true or false if the key was not on the
	// list, but it should aim to return false with a high probability.
	KeyMayMatch(key []byte, filter []byte) bool

	// Return the name of this policy.
	Name() string
}

FilterPolicy is a factory type that allows the RocksDB database to create a filter, such as a bloom filter, which will used to reduce reads.

func NewBloomFilter

func NewBloomFilter(bitsPerKey int) FilterPolicy

NewBloomFilter returns a new filter policy that uses a bloom filter with approximately the specified number of bits per key. A good value for bits_per_key is 10, which yields a filter with ~1% false positive rate.

Note: if you are using a custom comparator that ignores some parts of the keys being compared, you must not use NewBloomFilterPolicy() and must provide your own FilterPolicy that also ignores the corresponding parts of the keys. For example, if the comparator ignores trailing spaces, it would be incorrect to use a FilterPolicy (like NewBloomFilterPolicy) that does not ignore trailing spaces in keys.

func NewNativeFilterPolicy

func NewNativeFilterPolicy(c *C.rdb_filterpolicy_t) FilterPolicy

NewNativeFilterPolicy creates a FilterPolicy object.

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator provides a way to seek to specific keys and iterate through the keyspace from that point, as well as access the values of those keys.

For example:

 it := rdb.NewIterator(readOpts)
 defer it.Close()

 it.Seek([]byte("foo"))
		for ; it.Valid(); it.Next() {
   fmt.Printf("Key: %v Value: %v\n", it.Key().Data(), it.Value().Data())
 }

 if err := it.Err(); err != nil {
   return err
 }

func NewNativeIterator

func NewNativeIterator(c unsafe.Pointer) *Iterator

NewNativeIterator creates a Iterator object.

func (*Iterator) Close

func (iter *Iterator) Close()

Close closes the iterator.

func (*Iterator) Err

func (iter *Iterator) Err() error

Err returns nil if no errors happened during iteration, or the actual error otherwise.

func (*Iterator) Key

func (iter *Iterator) Key() *Slice

Key returns the key the iterator currently holds.

func (*Iterator) Next

func (iter *Iterator) Next()

Next moves the iterator to the next sequential key in the database.

func (*Iterator) Prev

func (iter *Iterator) Prev()

Prev moves the iterator to the previous sequential key in the database.

func (*Iterator) Seek

func (iter *Iterator) Seek(key []byte)

Seek moves the iterator to the position greater than or equal to the key.

func (*Iterator) SeekToFirst

func (iter *Iterator) SeekToFirst()

SeekToFirst moves the iterator to the first key in the database.

func (*Iterator) SeekToLast

func (iter *Iterator) SeekToLast()

SeekToLast moves the iterator to the last key in the database.

func (*Iterator) Valid

func (iter *Iterator) Valid() bool

Valid returns false only when an Iterator has iterated past either the first or the last key in the database.

func (*Iterator) ValidForPrefix

func (iter *Iterator) ValidForPrefix(prefix []byte) bool

ValidForPrefix returns false only when an Iterator has iterated past the first or the last key in the database or the specified prefix.

func (*Iterator) Value

func (iter *Iterator) Value() *Slice

Value returns the value in the database the iterator currently holds.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options represent all of the available options when opening a database with Open.

func NewDefaultOptions

func NewDefaultOptions() *Options

NewDefaultOptions creates the default Options.

func NewNativeOptions

func NewNativeOptions(c *C.rdb_options_t) *Options

NewNativeOptions creates a Options object.

func (*Options) SetBlockBasedTableFactory

func (opts *Options) SetBlockBasedTableFactory(value *BlockBasedTableOptions)

SetBlockBasedTableFactory sets the block based table factory.

func (*Options) SetCreateIfMissing

func (opts *Options) SetCreateIfMissing(value bool)

SetCreateIfMissing specifies whether the database should be created if it is missing. Default: false

type Range

type Range struct {
	Start []byte
	Limit []byte
}

Range is a range of keys in the database. GetApproximateSizes calls with it begin at the key Start and end right before the key Limit.

type ReadOptions

type ReadOptions struct {
	// contains filtered or unexported fields
}

ReadOptions represent all of the available options when reading from a database.

func NewDefaultReadOptions

func NewDefaultReadOptions() *ReadOptions

NewDefaultReadOptions creates a default ReadOptions object.

func NewNativeReadOptions

func NewNativeReadOptions(c *C.rdb_readoptions_t) *ReadOptions

NewNativeReadOptions creates a ReadOptions object.

func (*ReadOptions) Destroy

func (opts *ReadOptions) Destroy()

Destroy deallocates the ReadOptions object.

func (*ReadOptions) SetFillCache

func (opts *ReadOptions) SetFillCache(value bool)

SetFillCache specify whether the "data block"/"index block"/"filter block" read for this iteration should be cached in memory? Callers may wish to set this field to false for bulk scans. Default: true

func (*ReadOptions) SetSnapshot

func (opts *ReadOptions) SetSnapshot(snapshot *Snapshot)

SetSnapshot updates the default read options to use the given snapshot.

type Slice

type Slice struct {
	// contains filtered or unexported fields
}

Slice is used as a wrapper for non-copy values

func NewSlice

func NewSlice(data *C.char, size C.size_t) *Slice

NewSlice returns a slice with the given data.

func (*Slice) Data

func (s *Slice) Data() []byte

Data returns the data of the slice.

func (*Slice) Free

func (s *Slice) Free()

Free frees the slice data.

func (*Slice) Size

func (s *Slice) Size() int

Size returns the size of the data.

type Snapshot

type Snapshot struct {
	// contains filtered or unexported fields
}

Snapshot provides a consistent view of read operations in a DB.

func NewNativeSnapshot

func NewNativeSnapshot(c *C.rdb_snapshot_t, cDb *C.rdb_t) *Snapshot

NewNativeSnapshot creates a Snapshot object.

func (*Snapshot) Release

func (s *Snapshot) Release()

Release removes the snapshot from the database's list of snapshots.

type WriteBatch

type WriteBatch struct {
	// contains filtered or unexported fields
}

WriteBatch is a batching of Puts, Merges and Deletes.

func NewNativeWriteBatch

func NewNativeWriteBatch(c *C.rdb_writebatch_t) *WriteBatch

NewNativeWriteBatch create a WriteBatch object.

func NewWriteBatch

func NewWriteBatch() *WriteBatch

NewWriteBatch create a WriteBatch object.

func WriteBatchFrom

func WriteBatchFrom(data []byte) *WriteBatch

WriteBatchFrom creates a write batch from a serialized WriteBatch.

func (*WriteBatch) Clear

func (wb *WriteBatch) Clear()

Clear removes all the enqueued Put and Deletes.

func (*WriteBatch) Count

func (wb *WriteBatch) Count() int

Count returns the number of updates in the batch.

func (*WriteBatch) Delete

func (wb *WriteBatch) Delete(key []byte)

Delete queues a deletion of the data at key.

func (*WriteBatch) Destroy

func (wb *WriteBatch) Destroy()

Destroy deallocates the WriteBatch object.

func (*WriteBatch) Put

func (wb *WriteBatch) Put(key, value []byte)

Put queues a key-value pair.

type WriteOptions

type WriteOptions struct {
	// contains filtered or unexported fields
}

WriteOptions represent all of the available options when writing to a database.

func NewDefaultWriteOptions

func NewDefaultWriteOptions() *WriteOptions

NewDefaultWriteOptions creates a default WriteOptions object.

func NewNativeWriteOptions

func NewNativeWriteOptions(c *C.rdb_writeoptions_t) *WriteOptions

NewNativeWriteOptions creates a WriteOptions object.

func (*WriteOptions) Destroy

func (opts *WriteOptions) Destroy()

Destroy deallocates the WriteOptions object.

func (*WriteOptions) SetSync

func (opts *WriteOptions) SetSync(value bool)

SetSync sets the sync mode. If true, the write will be flushed from the operating system buffer cache before the write is considered complete. If this flag is true, writes will be slower. Default: false

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL