public class RocksDB extends RocksObject
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_COLUMN_FAMILY |
static int |
NOT_FOUND |
protected DBOptionsInterface |
options_ |
nativeHandle_
Modifier | Constructor and Description |
---|---|
protected |
RocksDB()
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the RocksDB instance.
|
ColumnFamilyHandle |
createColumnFamily(ColumnFamilyDescriptor columnFamilyDescriptor)
Creates a new column family with the name columnFamilyName and
allocates a ColumnFamilyHandle within an internal structure.
|
protected void |
disposeInternal()
The helper function of
dispose() which all subclasses of
RocksObject must implement to release their associated
C++ resource. |
void |
dropColumnFamily(ColumnFamilyHandle columnFamilyHandle)
Drops the column family identified by columnFamilyName.
|
void |
flush(FlushOptions flushOptions)
Flush all memory table data.
|
void |
flush(FlushOptions flushOptions,
ColumnFamilyHandle columnFamilyHandle)
Flush all memory table data.
|
byte[] |
get(byte[] key)
The simplified version of get which returns a new byte array storing
the value associated with the specified input key if any.
|
int |
get(byte[] key,
byte[] value)
Get the value associated with the specified key within column family*
|
byte[] |
get(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
The simplified version of get which returns a new byte array storing
the value associated with the specified input key if any.
|
int |
get(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
byte[] value)
Get the value associated with the specified key within column family.
|
byte[] |
get(ColumnFamilyHandle columnFamilyHandle,
ReadOptions opt,
byte[] key)
The simplified version of get which returns a new byte array storing
the value associated with the specified input key if any.
|
int |
get(ColumnFamilyHandle columnFamilyHandle,
ReadOptions opt,
byte[] key,
byte[] value)
Get the value associated with the specified key within column family.
|
protected byte[] |
get(long handle,
byte[] key,
int keyLen) |
protected int |
get(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected int |
get(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
protected byte[] |
get(long handle,
byte[] key,
int keyLen,
long cfHandle) |
protected byte[] |
get(long handle,
long readOptHandle,
byte[] key,
int keyLen) |
protected int |
get(long handle,
long readOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected int |
get(long handle,
long readOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
protected byte[] |
get(long handle,
long readOptHandle,
byte[] key,
int keyLen,
long cfHandle) |
byte[] |
get(ReadOptions opt,
byte[] key)
The simplified version of get which returns a new byte array storing
the value associated with the specified input key if any.
|
int |
get(ReadOptions opt,
byte[] key,
byte[] value)
Get the value associated with the specified key.
|
long |
getLongProperty(ColumnFamilyHandle columnFamilyHandle,
java.lang.String property)
Similar to GetProperty(), but only works for a subset of properties whose
return value is a numerical value.
|
protected long |
getLongProperty(long nativeHandle,
long cfHandle,
java.lang.String property,
int propertyLength) |
protected long |
getLongProperty(long nativeHandle,
java.lang.String property,
int propertyLength) |
long |
getLongProperty(java.lang.String property)
Similar to GetProperty(), but only works for a subset of properties whose
return value is a numerical value.
|
java.lang.String |
getProperty(ColumnFamilyHandle columnFamilyHandle,
java.lang.String property)
DB implements can export properties about their state
via this method on a per column family level.
|
java.lang.String |
getProperty(java.lang.String property)
DB implementations can export properties about their state
via this method.
|
protected java.lang.String |
getProperty0(long nativeHandle,
long cfHandle,
java.lang.String property,
int propertyLength) |
protected java.lang.String |
getProperty0(long nativeHandle,
java.lang.String property,
int propertyLength) |
Snapshot |
getSnapshot()
Return a handle to the current DB state.
|
protected long |
getSnapshot(long nativeHandle) |
protected long |
iterator0(long handle) |
protected long |
iterator0(long handle,
long cfHandle) |
protected long[] |
iterators(long handle,
java.util.List<ColumnFamilyHandle> columnFamilyNames) |
protected boolean |
keyMayExist(byte[] key,
int keyLen,
long cfHandle,
java.lang.StringBuffer stringBuffer) |
protected boolean |
keyMayExist(byte[] key,
int keyLen,
java.lang.StringBuffer stringBuffer) |
boolean |
keyMayExist(byte[] key,
java.lang.StringBuffer value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
java.lang.StringBuffer value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
protected boolean |
keyMayExist(long optionsHandle,
byte[] key,
int keyLen,
long cfHandle,
java.lang.StringBuffer stringBuffer) |
protected boolean |
keyMayExist(long optionsHandle,
byte[] key,
int keyLen,
java.lang.StringBuffer stringBuffer) |
boolean |
keyMayExist(ReadOptions readOptions,
byte[] key,
java.lang.StringBuffer value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(ReadOptions readOptions,
ColumnFamilyHandle columnFamilyHandle,
byte[] key,
java.lang.StringBuffer value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
protected static java.util.List<byte[]> |
listColumnFamilies(long optionsHandle,
java.lang.String path) |
static java.util.List<byte[]> |
listColumnFamilies(Options options,
java.lang.String path)
Static method to determine all available column families for a
rocksdb database identified by path
|
static void |
loadLibrary()
Loads the necessary library files.
|
static void |
loadLibrary(java.util.List<java.lang.String> paths)
Tries to load the necessary library files from the given list of
directories.
|
void |
merge(byte[] key,
byte[] value)
Add merge operand for key/value pair.
|
void |
merge(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
byte[] value)
Add merge operand for key/value pair in a ColumnFamily.
|
void |
merge(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpts,
byte[] key,
byte[] value)
Add merge operand for key/value pair.
|
protected void |
merge(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected void |
merge(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
protected void |
merge(long handle,
long writeOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected void |
merge(long handle,
long writeOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
void |
merge(WriteOptions writeOpts,
byte[] key,
byte[] value)
Add merge operand for key/value pair.
|
java.util.Map<byte[],byte[]> |
multiGet(java.util.List<byte[]> keys)
Returns a map of keys for which values were found in DB.
|
java.util.Map<byte[],byte[]> |
multiGet(java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Returns a map of keys for which values were found in DB.
|
protected java.util.List<byte[]> |
multiGet(long dbHandle,
java.util.List<byte[]> keys,
int keysCount) |
protected java.util.List<byte[]> |
multiGet(long dbHandle,
java.util.List<byte[]> keys,
int keysCount,
java.util.List<ColumnFamilyHandle> cfHandles) |
protected java.util.List<byte[]> |
multiGet(long dbHandle,
long rOptHandle,
java.util.List<byte[]> keys,
int keysCount) |
protected java.util.List<byte[]> |
multiGet(long dbHandle,
long rOptHandle,
java.util.List<byte[]> keys,
int keysCount,
java.util.List<ColumnFamilyHandle> cfHandles) |
java.util.Map<byte[],byte[]> |
multiGet(ReadOptions opt,
java.util.List<byte[]> keys)
Returns a map of keys for which values were found in DB.
|
java.util.Map<byte[],byte[]> |
multiGet(ReadOptions opt,
java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Returns a map of keys for which values were found in DB.
|
RocksIterator |
newIterator()
Return a heap-allocated iterator over the contents of the database.
|
RocksIterator |
newIterator(ColumnFamilyHandle columnFamilyHandle)
Return a heap-allocated iterator over the contents of the database.
|
java.util.List<RocksIterator> |
newIterators(java.util.List<ColumnFamilyHandle> columnFamilyHandleList)
Returns iterators from a consistent database state across multiple
column families.
|
static RocksDB |
open(DBOptions options,
java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
java.util.List<ColumnFamilyHandle> columnFamilyHandles)
The factory constructor of RocksDB that opens a RocksDB instance given
the path to the database using the specified options and db path and a list
of column family names.
|
protected void |
open(long optionsHandle,
java.lang.String path) |
protected java.util.List<java.lang.Long> |
open(long optionsHandle,
java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
int columnFamilyDescriptorsLength) |
static RocksDB |
open(Options options,
java.lang.String path)
The factory constructor of RocksDB that opens a RocksDB instance given
the path to the database using the specified options and db path.
|
static RocksDB |
open(java.lang.String path)
The factory constructor of RocksDB that opens a RocksDB instance given
the path to the database using the default options w/ createIfMissing
set to true.
|
static RocksDB |
open(java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
java.util.List<ColumnFamilyHandle> columnFamilyHandles)
The factory constructor of RocksDB that opens a RocksDB instance given
the path to the database using the specified options and db path and a list
of column family names.
|
static RocksDB |
openReadOnly(DBOptions options,
java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
java.util.List<ColumnFamilyHandle> columnFamilyHandles)
The factory constructor of RocksDB that opens a RocksDB instance in
Read-Only mode given the path to the database using the specified
options and db path.
|
static RocksDB |
openReadOnly(Options options,
java.lang.String path)
The factory constructor of RocksDB that opens a RocksDB instance in
Read-Only mode given the path to the database using the specified
options and db path.
|
static RocksDB |
openReadOnly(java.lang.String path)
The factory constructor of RocksDB that opens a RocksDB instance in
Read-Only mode given the path to the database using the default
options.
|
static RocksDB |
openReadOnly(java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
java.util.List<ColumnFamilyHandle> columnFamilyHandles)
The factory constructor of RocksDB that opens a RocksDB instance in
Read-Only mode given the path to the database using the default
options.
|
protected void |
openROnly(long optionsHandle,
java.lang.String path) |
protected java.util.List<java.lang.Long> |
openROnly(long optionsHandle,
java.lang.String path,
java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors,
int columnFamilyDescriptorsLength) |
void |
put(byte[] key,
byte[] value)
Set the database entry for "key" to "value".
|
void |
put(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
byte[] value)
Set the database entry for "key" to "value" in the specified
column family.
|
void |
put(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpts,
byte[] key,
byte[] value)
Set the database entry for "key" to "value" for the specified
column family.
|
protected void |
put(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected void |
put(long handle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
protected void |
put(long handle,
long writeOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen) |
protected void |
put(long handle,
long writeOptHandle,
byte[] key,
int keyLen,
byte[] value,
int valueLen,
long cfHandle) |
void |
put(WriteOptions writeOpts,
byte[] key,
byte[] value)
Set the database entry for "key" to "value".
|
protected void |
releaseSnapshot(long nativeHandle,
long snapshotHandle) |
void |
releaseSnapshot(Snapshot snapshot)
Release a previously acquired snapshot.
|
void |
remove(byte[] key)
Remove the database entry (if any) for "key".
|
void |
remove(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Remove the database entry (if any) for "key".
|
void |
remove(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] key)
Remove the database entry (if any) for "key".
|
protected void |
remove(long handle,
byte[] key,
int keyLen) |
protected void |
remove(long handle,
byte[] key,
int keyLen,
long cfHandle) |
protected void |
remove(long handle,
long writeOptHandle,
byte[] key,
int keyLen) |
protected void |
remove(long handle,
long writeOptHandle,
byte[] key,
int keyLen,
long cfHandle) |
void |
remove(WriteOptions writeOpt,
byte[] key)
Remove the database entry (if any) for "key".
|
protected void |
write(long writeOptHandle,
long batchHandle) |
void |
write(WriteOptions writeOpts,
WriteBatch updates)
Apply the specified updates to the database.
|
disOwnNativeHandle, dispose, finalize, isInitialized, isOwningNativeHandle
public static final java.lang.String DEFAULT_COLUMN_FAMILY
public static final int NOT_FOUND
protected DBOptionsInterface options_
public static void loadLibrary()
public static void loadLibrary(java.util.List<java.lang.String> paths)
paths
- a list of strings where each describes a directory
of a library.public static RocksDB open(java.lang.String path) throws RocksDBException
path
- the path to the rocksdb.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.Options.setCreateIfMissing(boolean)
public static RocksDB open(java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
If opened in read write mode every existing column family name must be passed within the list to this method.
If opened in read-only mode only a subset of existing column families must be passed to this method.
Options instance *should* not be disposed before all DBs using this options instance have been closed. If user doesn't call options dispose explicitly, then this options instance will be GC'd automatically
ColumnFamily handles are disposed when the RocksDB instance is disposed.
path
- the path to the rocksdb.columnFamilyDescriptors
- list of column family descriptorscolumnFamilyHandles
- will be filled with ColumnFamilyHandle instances
on open.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.DBOptions.setCreateIfMissing(boolean)
public static RocksDB open(Options options, java.lang.String path) throws RocksDBException
Options instance *should* not be disposed before all DBs using this options instance have been closed. If user doesn't call options dispose explicitly, then this options instance will be GC'd automatically.
Options instance can be re-used to open multiple DBs if DB statistics is not used. If DB statistics are required, then its recommended to open DB with new Options instance as underlying native statistics instance does not use any locks to prevent concurrent updates.
options
- Options
instance.path
- the path to the rocksdb.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.Options.setCreateIfMissing(boolean)
public static RocksDB open(DBOptions options, java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
If opened in read write mode every existing column family name must be passed within the list to this method.
If opened in read-only mode only a subset of existing column families must be passed to this method.
Options instance *should* not be disposed before all DBs using this options instance have been closed. If user doesn't call options dispose explicitly, then this options instance will be GC'd automatically.
Options instance can be re-used to open multiple DBs if DB statistics is not used. If DB statistics are required, then its recommended to open DB with new Options instance as underlying native statistics instance does not use any locks to prevent concurrent updates.
ColumnFamily handles are disposed when the RocksDB instance is disposed.
options
- DBOptions
instance.path
- the path to the rocksdb.columnFamilyDescriptors
- list of column family descriptorscolumnFamilyHandles
- will be filled with ColumnFamilyHandle instances
on open.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.DBOptions.setCreateIfMissing(boolean)
public static RocksDB openReadOnly(java.lang.String path) throws RocksDBException
path
- the path to the RocksDB.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.public static RocksDB openReadOnly(java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
path
- the path to the RocksDB.columnFamilyDescriptors
- list of column family descriptorscolumnFamilyHandles
- will be filled with ColumnFamilyHandle instances
on open.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.public static RocksDB openReadOnly(Options options, java.lang.String path) throws RocksDBException
options
- Options
instance.path
- the path to the RocksDB.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.public static RocksDB openReadOnly(DBOptions options, java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
This open method allows to open RocksDB using a subset of available column families
Options instance *should* not be disposed before all DBs using this options instance have been closed. If user doesn't call options dispose explicitly,then this options instance will be GC'd automatically.
options
- DBOptions
instance.path
- the path to the RocksDB.columnFamilyDescriptors
- list of column family descriptorscolumnFamilyHandles
- will be filled with ColumnFamilyHandle instances
on open.RocksDB
instance on success, null if the specified
RocksDB
can not be opened.RocksDBException
- thrown if error happens in underlying
native library.public static java.util.List<byte[]> listColumnFamilies(Options options, java.lang.String path) throws RocksDBException
options
- Options for opening the databasepath
- Absolute path to rocksdb databaseRocksDBException
- thrown if error happens in underlying
native library.protected void disposeInternal()
RocksObject
dispose()
which all subclasses of
RocksObject
must implement to release their associated
C++ resource.disposeInternal
in class RocksObject
public void close()
public void put(byte[] key, byte[] value) throws RocksDBException
key
- the specified key to be inserted.value
- the value associated with the specified key.RocksDBException
- thrown if error happens in underlying
native library.public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be inserted.value
- the value associated with the specified key.
throws IllegalArgumentException if column family is not presentRocksDBException
- thrown if error happens in underlying
native library.public void put(WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
writeOpts
- WriteOptions
instance.key
- the specified key to be inserted.value
- the value associated with the specified key.RocksDBException
- thrown if error happens in underlying
native library.public void put(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpts
- WriteOptions
instance.key
- the specified key to be inserted.value
- the value associated with the specified key.
throws IllegalArgumentException if column family is not presentRocksDBException
- thrown if error happens in underlying
native library.IllegalArgumentException
public boolean keyMayExist(byte[] key, java.lang.StringBuffer value)
key
- byte array of a key to search forvalue
- StringBuffer instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, java.lang.StringBuffer value)
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search forvalue
- StringBuffer instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ReadOptions readOptions, byte[] key, java.lang.StringBuffer value)
readOptions
- ReadOptions
instancekey
- byte array of a key to search forvalue
- StringBuffer instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, java.lang.StringBuffer value)
readOptions
- ReadOptions
instancecolumnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search forvalue
- StringBuffer instance which is a out parameter if a value is
found in block-cache.public void write(WriteOptions writeOpts, WriteBatch updates) throws RocksDBException
writeOpts
- WriteOptions instanceupdates
- WriteBatch instanceRocksDBException
- thrown if error happens in underlying
native library.public void merge(byte[] key, byte[] value) throws RocksDBException
key
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying
native library.public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying
native library.public void merge(WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
writeOpts
- WriteOptions
for this write.key
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying
native library.public void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpts
- WriteOptions
for this write.key
- the specified key to be merged.value
- the value to be merged with the current value for
the specified key.RocksDBException
- thrown if error happens in underlying
native library.public int get(byte[] key, byte[] value) throws RocksDBException
key
- the key to retrieve the value.value
- the out-value to receive the retrieved value.key
in byte. If the return value is greater than the
length of value
, then it indicates that the size of the
input buffer value
is insufficient and partial result will
be returned. RocksDB.NOT_FOUND will be returned if the value not
found.RocksDBException
- thrown if error happens in underlying
native library.public int get(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException, java.lang.IllegalArgumentException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key to retrieve the value.value
- the out-value to receive the retrieved value.key
in byte. If the return value is greater than the
length of value
, then it indicates that the size of the
input buffer value
is insufficient and partial result will
be returned. RocksDB.NOT_FOUND will be returned if the value not
found.RocksDBException
- thrown if error happens in underlying
native library.java.lang.IllegalArgumentException
public int get(ReadOptions opt, byte[] key, byte[] value) throws RocksDBException
opt
- ReadOptions
instance.key
- the key to retrieve the value.value
- the out-value to receive the retrieved value.key
in byte. If the return value is greater than the
length of value
, then it indicates that the size of the
input buffer value
is insufficient and partial result will
be returned. RocksDB.NOT_FOUND will be returned if the value not
found.RocksDBException
- thrown if error happens in underlying
native library.public int get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, byte[] value) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instanceopt
- ReadOptions
instance.key
- the key to retrieve the value.value
- the out-value to receive the retrieved value.key
in byte. If the return value is greater than the
length of value
, then it indicates that the size of the
input buffer value
is insufficient and partial result will
be returned. RocksDB.NOT_FOUND will be returned if the value not
found.RocksDBException
- thrown if error happens in underlying
native library.public byte[] get(byte[] key) throws RocksDBException
key
- the key retrieve the value.RocksDBException
- thrown if error happens in underlying
native library.public byte[] get(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key retrieve the value.RocksDBException
- thrown if error happens in underlying
native library.public byte[] get(ReadOptions opt, byte[] key) throws RocksDBException
key
- the key retrieve the value.opt
- Read options.RocksDBException
- thrown if error happens in underlying
native library.public byte[] get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key retrieve the value.opt
- Read options.RocksDBException
- thrown if error happens in underlying
native library.public java.util.Map<byte[],byte[]> multiGet(java.util.List<byte[]> keys) throws RocksDBException
keys
- List of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.public java.util.Map<byte[],byte[]> multiGet(java.util.List<ColumnFamilyHandle> columnFamilyHandleList, java.util.List<byte[]> keys) throws RocksDBException, java.lang.IllegalArgumentException
Note: Every key needs to have a related column family name in
columnFamilyHandleList
.
columnFamilyHandleList
- List
containing
ColumnFamilyHandle
instances.keys
- List of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.java.lang.IllegalArgumentException
- thrown if the size of passed keys is not
equal to the amount of passed column family handles.public java.util.Map<byte[],byte[]> multiGet(ReadOptions opt, java.util.List<byte[]> keys) throws RocksDBException
opt
- Read options.keys
- of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.public java.util.Map<byte[],byte[]> multiGet(ReadOptions opt, java.util.List<ColumnFamilyHandle> columnFamilyHandleList, java.util.List<byte[]> keys) throws RocksDBException
Note: Every key needs to have a related column family name in
columnFamilyHandleList
.
opt
- Read options.columnFamilyHandleList
- List
containing
ColumnFamilyHandle
instances.keys
- of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.java.lang.IllegalArgumentException
- thrown if the size of passed keys is not
equal to the amount of passed column family handles.public void remove(byte[] key) throws RocksDBException
key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void remove(WriteOptions writeOpt, byte[] key) throws RocksDBException
writeOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void remove(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public java.lang.String getProperty(ColumnFamilyHandle columnFamilyHandle, java.lang.String property) throws RocksDBException
If property
is a valid property understood by this DB
implementation, fills value
with its current value and
returns true. Otherwise returns false.
Valid property names include:
columnFamilyHandle
- ColumnFamilyHandle
instanceproperty
- to be fetched. See above for examplesRocksDBException
- thrown if error happens in underlying
native library.public java.lang.String getProperty(java.lang.String property) throws RocksDBException
Valid property names include:
property
- to be fetched. See above for examplesRocksDBException
- thrown if error happens in underlying
native library.public long getLongProperty(java.lang.String property) throws RocksDBException
Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value. Return the value as long.
Note: As the returned property is of type
uint64_t
on C++ side the returning value can be negative
because Java supports in Java 7 only signed long values.
Java 7: To mitigate the problem of the non
existent unsigned long tpye, values should be encapsulated using
BigInteger
to reflect the correct value. The correct
behavior is guaranteed if 2^64
is added to negative values.
Java 8: In Java 8 the value should be treated as
unsigned long using provided methods of type Long
.
property
- to be fetched.RocksDBException
- if an error happens in the underlying native code.public long getLongProperty(ColumnFamilyHandle columnFamilyHandle, java.lang.String property) throws RocksDBException
Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value. Return the value as long.
Note: As the returned property is of type
uint64_t
on C++ side the returning value can be negative
because Java supports in Java 7 only signed long values.
Java 7: To mitigate the problem of the non
existent unsigned long tpye, values should be encapsulated using
BigInteger
to reflect the correct value. The correct
behavior is guaranteed if 2^64
is added to negative values.
Java 8: In Java 8 the value should be treated as
unsigned long using provided methods of type Long
.
columnFamilyHandle
- ColumnFamilyHandle
instanceproperty
- to be fetched.RocksDBException
- if an error happens in the underlying native code.public RocksIterator newIterator()
public Snapshot getSnapshot()
Return a handle to the current DB state. Iterators created with this handle will all observe a stable snapshot of the current DB state. The caller must call ReleaseSnapshot(result) when the snapshot is no longer needed.
nullptr will be returned if the DB fails to take a snapshot or does not support snapshot.
Snapshot
instancepublic void releaseSnapshot(Snapshot snapshot)
snapshot
- Snapshot
instancepublic RocksIterator newIterator(ColumnFamilyHandle columnFamilyHandle)
columnFamilyHandle
- ColumnFamilyHandle
instancepublic java.util.List<RocksIterator> newIterators(java.util.List<ColumnFamilyHandle> columnFamilyHandleList) throws RocksDBException
columnFamilyHandleList
- List
containing
ColumnFamilyHandle
instances.List
containing RocksIterator
instancesRocksDBException
- thrown if error happens in underlying
native library.public ColumnFamilyHandle createColumnFamily(ColumnFamilyDescriptor columnFamilyDescriptor) throws RocksDBException
columnFamilyDescriptor
- column family to be created.ColumnFamilyHandle
instance.RocksDBException
- thrown if error happens in underlying
native library.public void dropColumnFamily(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException, java.lang.IllegalArgumentException
columnFamilyHandle
- ColumnFamilyHandle
instanceRocksDBException
- thrown if error happens in underlying
native library.java.lang.IllegalArgumentException
public void flush(FlushOptions flushOptions) throws RocksDBException
Flush all memory table data.
Note: it must be ensured that the FlushOptions instance is not GC'ed before this method finishes. If the wait parameter is set to false, flush processing is asynchronous.
flushOptions
- FlushOptions
instance.RocksDBException
- thrown if an error occurs within the native
part of the library.public void flush(FlushOptions flushOptions, ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
Flush all memory table data.
Note: it must be ensured that the FlushOptions instance is not GC'ed before this method finishes. If the wait parameter is set to false, flush processing is asynchronous.
flushOptions
- FlushOptions
instance.columnFamilyHandle
- ColumnFamilyHandle
instance.RocksDBException
- thrown if an error occurs within the native
part of the library.protected void open(long optionsHandle, java.lang.String path) throws RocksDBException
RocksDBException
protected java.util.List<java.lang.Long> open(long optionsHandle, java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, int columnFamilyDescriptorsLength) throws RocksDBException
RocksDBException
protected static java.util.List<byte[]> listColumnFamilies(long optionsHandle, java.lang.String path) throws RocksDBException
RocksDBException
protected void openROnly(long optionsHandle, java.lang.String path) throws RocksDBException
RocksDBException
protected java.util.List<java.lang.Long> openROnly(long optionsHandle, java.lang.String path, java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors, int columnFamilyDescriptorsLength) throws RocksDBException
RocksDBException
protected void put(long handle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected void put(long handle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected void put(long handle, long writeOptHandle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected void put(long handle, long writeOptHandle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected void write(long writeOptHandle, long batchHandle) throws RocksDBException
RocksDBException
protected boolean keyMayExist(byte[] key, int keyLen, java.lang.StringBuffer stringBuffer)
protected boolean keyMayExist(byte[] key, int keyLen, long cfHandle, java.lang.StringBuffer stringBuffer)
protected boolean keyMayExist(long optionsHandle, byte[] key, int keyLen, java.lang.StringBuffer stringBuffer)
protected boolean keyMayExist(long optionsHandle, byte[] key, int keyLen, long cfHandle, java.lang.StringBuffer stringBuffer)
protected void merge(long handle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected void merge(long handle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected void merge(long handle, long writeOptHandle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected void merge(long handle, long writeOptHandle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected int get(long handle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected int get(long handle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected int get(long handle, long readOptHandle, byte[] key, int keyLen, byte[] value, int valueLen) throws RocksDBException
RocksDBException
protected int get(long handle, long readOptHandle, byte[] key, int keyLen, byte[] value, int valueLen, long cfHandle) throws RocksDBException
RocksDBException
protected java.util.List<byte[]> multiGet(long dbHandle, java.util.List<byte[]> keys, int keysCount)
protected java.util.List<byte[]> multiGet(long dbHandle, java.util.List<byte[]> keys, int keysCount, java.util.List<ColumnFamilyHandle> cfHandles)
protected java.util.List<byte[]> multiGet(long dbHandle, long rOptHandle, java.util.List<byte[]> keys, int keysCount)
protected java.util.List<byte[]> multiGet(long dbHandle, long rOptHandle, java.util.List<byte[]> keys, int keysCount, java.util.List<ColumnFamilyHandle> cfHandles)
protected byte[] get(long handle, byte[] key, int keyLen) throws RocksDBException
RocksDBException
protected byte[] get(long handle, byte[] key, int keyLen, long cfHandle) throws RocksDBException
RocksDBException
protected byte[] get(long handle, long readOptHandle, byte[] key, int keyLen) throws RocksDBException
RocksDBException
protected byte[] get(long handle, long readOptHandle, byte[] key, int keyLen, long cfHandle) throws RocksDBException
RocksDBException
protected void remove(long handle, byte[] key, int keyLen) throws RocksDBException
RocksDBException
protected void remove(long handle, byte[] key, int keyLen, long cfHandle) throws RocksDBException
RocksDBException
protected void remove(long handle, long writeOptHandle, byte[] key, int keyLen) throws RocksDBException
RocksDBException
protected void remove(long handle, long writeOptHandle, byte[] key, int keyLen, long cfHandle) throws RocksDBException
RocksDBException
protected java.lang.String getProperty0(long nativeHandle, java.lang.String property, int propertyLength) throws RocksDBException
RocksDBException
protected java.lang.String getProperty0(long nativeHandle, long cfHandle, java.lang.String property, int propertyLength) throws RocksDBException
RocksDBException
protected long getLongProperty(long nativeHandle, java.lang.String property, int propertyLength) throws RocksDBException
RocksDBException
protected long getLongProperty(long nativeHandle, long cfHandle, java.lang.String property, int propertyLength) throws RocksDBException
RocksDBException
protected long iterator0(long handle)
protected long iterator0(long handle, long cfHandle)
protected long[] iterators(long handle, java.util.List<ColumnFamilyHandle> columnFamilyNames) throws RocksDBException
RocksDBException
protected long getSnapshot(long nativeHandle)
protected void releaseSnapshot(long nativeHandle, long snapshotHandle)