Documentation ¶
Index ¶
- type BlockBasedTableOptions
- func (opts *BlockBasedTableOptions) Destroy()
- func (opts *BlockBasedTableOptions) SetBlockCache(cache *Cache)
- func (opts *BlockBasedTableOptions) SetBlockCacheCompressed(cache *Cache)
- func (opts *BlockBasedTableOptions) SetBlockSize(blockSize int)
- func (opts *BlockBasedTableOptions) SetFilterPolicy(fp FilterPolicy)
- func (opts *BlockBasedTableOptions) SetNoBlockCache(value bool)
- func (opts *BlockBasedTableOptions) SetWholeKeyFiltering(value bool)
- type Cache
- type Checkpoint
- type DB
- func (db *DB) Close()
- func (db *DB) Delete(opts *WriteOptions, key []byte) error
- func (db *DB) Get(opts *ReadOptions, key []byte) (*Slice, error)
- func (db *DB) GetBytes(opts *ReadOptions, key []byte) ([]byte, error)
- func (db *DB) GetProperty(propName string) string
- func (db *DB) GetStats() string
- func (db *DB) NewCheckpoint() (*Checkpoint, error)
- func (db *DB) NewIterator(opts *ReadOptions) *Iterator
- func (db *DB) NewSnapshot() *Snapshot
- func (db *DB) Put(opts *WriteOptions, key, value []byte) error
- func (db *DB) Write(opts *WriteOptions, batch *WriteBatch) error
- type FilterPolicy
- type Iterator
- func (iter *Iterator) Close()
- func (iter *Iterator) Err() error
- func (iter *Iterator) Key() *Slice
- func (iter *Iterator) Next()
- func (iter *Iterator) Prev()
- func (iter *Iterator) Seek(key []byte)
- func (iter *Iterator) SeekToFirst()
- func (iter *Iterator) SeekToLast()
- func (iter *Iterator) Valid() bool
- func (iter *Iterator) ValidForPrefix(prefix []byte) bool
- func (iter *Iterator) Value() *Slice
- type Options
- type Range
- type ReadOptions
- type Slice
- type Snapshot
- type WriteBatch
- type WriteOptions
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 ¶
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.
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 OpenDbForReadOnly ¶
OpenDbForReadOnly opens a database with the specified options for readonly usage.
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 ¶
GetProperty returns the value of a database property.
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 ¶
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 ¶
NewNativeIterator creates a Iterator object.
func (*Iterator) Err ¶
Err returns nil if no errors happened during iteration, or the actual error otherwise.
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) 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 ¶
Valid returns false only when an Iterator has iterated past either the first or the last key in the database.
func (*Iterator) ValidForPrefix ¶
ValidForPrefix returns false only when an Iterator has iterated past the first or the last key in the database or the specified prefix.
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 ¶
SetCreateIfMissing specifies whether the database should be created if it is missing. Default: false
type Range ¶
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
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.
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 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.
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