Class KeyValueStorageRocksDB
java.lang.Object
org.apache.bookkeeper.bookie.storage.ldb.KeyValueStorageRocksDB
- All Implemented Interfaces:
Closeable,AutoCloseable,KeyValueStorage
RocksDB based implementation of the KeyValueStorage.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.bookkeeper.bookie.storage.ldb.KeyValueStorage
KeyValueStorage.Batch, KeyValueStorage.CloseableIterator<T> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKeyValueStorageRocksDB(String basePath, String subPath, KeyValueStorageFactory.DbConfigType dbConfigType, ServerConfiguration conf) KeyValueStorageRocksDB(String basePath, String subPath, KeyValueStorageFactory.DbConfigType dbConfigType, ServerConfiguration conf, boolean readOnly) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcompact()Compact storage full range.voidcompact(byte[] firstKey, byte[] lastKey) Compact storage within a specified range.longcount()(package private) org.rocksdb.RocksDBdb()voiddelete(byte[] key) byte[]get(byte[] key) Get the value associated with the given key.intget(byte[] key, byte[] value) Get the value associated with the given key.Map.Entry<byte[],byte[]> getCeil(byte[] key) Get the entry whose key is bigger or equal the supplied key.(package private) List<org.rocksdb.ColumnFamilyDescriptor>Get storage path.Map.Entry<byte[],byte[]> getFloor(byte[] key) Get the entry whose key is the biggest and it's lesser than the supplied key.(package private) org.rocksdb.RocksObjectKeyValueStorage.CloseableIterator<Map.Entry<byte[],byte[]>> iterator()Return an iterator object that can be used to sequentially scan through all the entries in the database.keys()Get an iterator over to scan sequentially through all the keys in the database.keys(byte[] firstKey, byte[] lastKey) Get an iterator over to scan sequentially through all the keys within a specified range.newBatch()voidput(byte[] key, byte[] value) voidsync()Commit all pending write to durable storage.
-
Field Details
-
factory
-
-
Constructor Details
-
KeyValueStorageRocksDB
public KeyValueStorageRocksDB(String basePath, String subPath, KeyValueStorageFactory.DbConfigType dbConfigType, ServerConfiguration conf) throws IOException - Throws:
IOException
-
KeyValueStorageRocksDB
public KeyValueStorageRocksDB(String basePath, String subPath, KeyValueStorageFactory.DbConfigType dbConfigType, ServerConfiguration conf, boolean readOnly) throws IOException - Throws:
IOException
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
put
- Specified by:
putin interfaceKeyValueStorage- Throws:
IOException
-
get
Description copied from interface:KeyValueStorageGet the value associated with the given key.- Specified by:
getin interfaceKeyValueStorage- Parameters:
key- the key to lookup- Returns:
- the value or null if the key was not found
- Throws:
IOException
-
get
Description copied from interface:KeyValueStorageGet the value associated with the given key.This method will use the provided array store the value
- Specified by:
getin interfaceKeyValueStorage- Parameters:
key- the key to lookupvalue- an array where to store the result- Returns:
- -1 if the entry was not found or the length of the value
- Throws:
IOException- if the value array could not hold the result
-
getFloor
Description copied from interface:KeyValueStorageGet the entry whose key is the biggest and it's lesser than the supplied key.For example if the db contains :
{ 1 : 'a', 2 : 'b', 3 : 'c' }Then:
getFloor(3) --> (2, 'b')
- Specified by:
getFloorin interfaceKeyValueStorage- Parameters:
key- the non-inclusive upper limit key- Returns:
- the entry before or null if there's no entry before key
- Throws:
IOException
-
getCeil
Description copied from interface:KeyValueStorageGet the entry whose key is bigger or equal the supplied key.- Specified by:
getCeilin interfaceKeyValueStorage- Returns:
- Throws:
IOException
-
delete
- Specified by:
deletein interfaceKeyValueStorage- Throws:
IOException
-
getDBPath
Description copied from interface:KeyValueStorageGet storage path.- Specified by:
getDBPathin interfaceKeyValueStorage
-
compact
Description copied from interface:KeyValueStorageCompact storage within a specified range.- Specified by:
compactin interfaceKeyValueStorage- Parameters:
firstKey- the first key in the range (included)lastKey- the last key in the range (not included)- Throws:
IOException
-
compact
Description copied from interface:KeyValueStorageCompact storage full range.- Specified by:
compactin interfaceKeyValueStorage- Throws:
IOException
-
sync
Description copied from interface:KeyValueStorageCommit all pending write to durable storage.- Specified by:
syncin interfaceKeyValueStorage- Throws:
IOException
-
keys
Description copied from interface:KeyValueStorageGet an iterator over to scan sequentially through all the keys in the database.- Specified by:
keysin interfaceKeyValueStorage- Returns:
-
keys
Description copied from interface:KeyValueStorageGet an iterator over to scan sequentially through all the keys within a specified range.- Specified by:
keysin interfaceKeyValueStorage- Parameters:
firstKey- the first key in the range (included)lastKey- the lastKey in the range (not included)
-
iterator
Description copied from interface:KeyValueStorageReturn an iterator object that can be used to sequentially scan through all the entries in the database.- Specified by:
iteratorin interfaceKeyValueStorage
-
count
- Specified by:
countin interfaceKeyValueStorage- Returns:
- the number of keys.
- Throws:
IOException
-
newBatch
- Specified by:
newBatchin interfaceKeyValueStorage
-
db
org.rocksdb.RocksDB db() -
getColumnFamilyDescriptors
List<org.rocksdb.ColumnFamilyDescriptor> getColumnFamilyDescriptors() -
getOptions
org.rocksdb.RocksObject getOptions()
-