public class RocksDB extends RocksObject
Modifier and Type | Class and Description |
---|---|
static class |
RocksDB.CountAndSize |
static class |
RocksDB.LiveFiles |
Modifier and Type | Field and Description |
---|---|
static byte[] |
DEFAULT_COLUMN_FAMILY |
static int |
NOT_FOUND |
protected DBOptionsInterface |
options_ |
nativeHandle_
owningHandle_
Modifier | Constructor and Description |
---|---|
protected |
RocksDB(long nativeHandle)
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
This is similar to
closeE() except that it
silently ignores any errors. |
void |
closeE()
This is similar to
close() except that it
throws an exception if any error occurs. |
java.util.List<java.lang.String> |
compactFiles(CompactionOptions compactionOptions,
ColumnFamilyHandle columnFamilyHandle,
java.util.List<java.lang.String> inputFileNames,
int outputLevel,
int outputPathId,
CompactionJobInfo compactionJobInfo)
Takes a list of files specified by file names and
compacts them to the specified level.
|
java.util.List<java.lang.String> |
compactFiles(CompactionOptions compactionOptions,
java.util.List<java.lang.String> inputFileNames,
int outputLevel,
int outputPathId,
CompactionJobInfo compactionJobInfo)
Takes nputs a list of files specified by file names and
compacts them to the specified level.
|
void |
compactRange()
Range compaction of database.
|
void |
compactRange(boolean changeLevel,
int targetLevel,
int targetPathId)
Deprecated.
|
void |
compactRange(byte[] begin,
byte[] end)
Range compaction of database.
|
void |
compactRange(byte[] begin,
byte[] end,
boolean changeLevel,
int targetLevel,
int targetPathId)
Deprecated.
|
void |
compactRange(ColumnFamilyHandle columnFamilyHandle)
Range compaction of column family.
|
void |
compactRange(ColumnFamilyHandle columnFamilyHandle,
boolean changeLevel,
int targetLevel,
int targetPathId)
Deprecated.
|
void |
compactRange(ColumnFamilyHandle columnFamilyHandle,
byte[] begin,
byte[] end)
Range compaction of column family.
|
void |
compactRange(ColumnFamilyHandle columnFamilyHandle,
byte[] begin,
byte[] end,
boolean changeLevel,
int targetLevel,
int targetPathId)
Deprecated.
|
void |
compactRange(ColumnFamilyHandle columnFamilyHandle,
byte[] begin,
byte[] end,
CompactRangeOptions compactRangeOptions)
Range compaction of column family.
|
void |
continueBackgroundWork()
Resumes background work which was suspended by
previously calling
pauseBackgroundWork() |
java.util.List<ColumnFamilyHandle> |
createColumnFamilies(ColumnFamilyOptions columnFamilyOptions,
java.util.List<byte[]> columnFamilyNames)
Bulk create column families with the same column family options.
|
java.util.List<ColumnFamilyHandle> |
createColumnFamilies(java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors)
Bulk create column families with the same column family options.
|
ColumnFamilyHandle |
createColumnFamily(ColumnFamilyDescriptor columnFamilyDescriptor)
Creates a new column family with the name columnFamilyName and
allocates a ColumnFamilyHandle within an internal structure.
|
void |
delete(byte[] key)
Delete the database entry (if any) for "key".
|
void |
delete(byte[] key,
int offset,
int len)
Delete the database entry (if any) for "key".
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Delete the database entry (if any) for "key".
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
int offset,
int len)
Delete the database entry (if any) for "key".
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] key)
Delete the database entry (if any) for "key".
|
void |
delete(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] key,
int offset,
int len)
Delete the database entry (if any) for "key".
|
void |
delete(WriteOptions writeOpt,
byte[] key)
Delete the database entry (if any) for "key".
|
void |
delete(WriteOptions writeOpt,
byte[] key,
int offset,
int len)
Delete the database entry (if any) for "key".
|
void |
deleteFile(java.lang.String name)
Delete the file name from the db directory and update the internal state to
reflect that.
|
void |
deleteRange(byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
void |
deleteRange(ColumnFamilyHandle columnFamilyHandle,
byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
void |
deleteRange(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
void |
deleteRange(WriteOptions writeOpt,
byte[] beginKey,
byte[] endKey)
Removes the database entries in the range ["beginKey", "endKey"), i.e.,
including "beginKey" and excluding "endKey".
|
static void |
destroyDB(java.lang.String path,
Options options)
Static method to destroy the contents of the specified database.
|
void |
disableFileDeletions()
Prevent file deletions.
|
protected void |
disposeInternal(long handle) |
void |
dropColumnFamilies(java.util.List<ColumnFamilyHandle> columnFamilies) |
void |
dropColumnFamily(ColumnFamilyHandle columnFamilyHandle)
Drops the column family specified by
columnFamilyHandle . |
void |
enableAutoCompaction(java.util.List<ColumnFamilyHandle> columnFamilyHandles)
Enable automatic compactions for the given column
families if they were previously disabled.
|
void |
enableFileDeletions(boolean force)
Allow compactions to delete obsolete files.
|
void |
endTrace()
Stop tracing DB operations.
|
void |
flush(FlushOptions flushOptions)
Flush all memory table data.
|
void |
flush(FlushOptions flushOptions,
ColumnFamilyHandle columnFamilyHandle)
Flush all memory table data.
|
void |
flush(FlushOptions flushOptions,
java.util.List<ColumnFamilyHandle> columnFamilyHandles)
Flushes multiple column families.
|
void |
flushWal(boolean sync)
Flush the WAL memory buffer to the file.
|
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(byte[] key,
int offset,
int len)
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,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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,
byte[] key,
int offset,
int len)
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,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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.
|
byte[] |
get(ColumnFamilyHandle columnFamilyHandle,
ReadOptions opt,
byte[] key,
int offset,
int len)
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,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Get the value associated with the specified key within column family.
|
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.
|
byte[] |
get(ReadOptions opt,
byte[] key,
int offset,
int len)
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,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Get the value associated with the specified key.
|
long |
getAggregatedLongProperty(java.lang.String property)
Return sum of the getLongProperty of all the column families
|
RocksDB.CountAndSize |
getApproximateMemTableStats(ColumnFamilyHandle columnFamilyHandle,
Range range)
This method is similar to
getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...) ,
except that it returns approximate number of records and size in memtables. |
RocksDB.CountAndSize |
getApproximateMemTableStats(Range range)
This method is similar to
getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...) ,
except that it returns approximate number of records and size in memtables. |
long[] |
getApproximateSizes(ColumnFamilyHandle columnFamilyHandle,
java.util.List<Range> ranges,
SizeApproximationFlag... sizeApproximationFlags)
Get the approximate file system space used by keys in each range.
|
long[] |
getApproximateSizes(java.util.List<Range> ranges,
SizeApproximationFlag... sizeApproximationFlags)
Get the approximate file system space used by keys in each range for
the default column family.
|
ColumnFamilyMetaData |
GetColumnFamilyMetaData()
Obtains the meta data of the default column family of the DB.
|
ColumnFamilyMetaData |
getColumnFamilyMetaData(ColumnFamilyHandle columnFamilyHandle)
Obtains the meta data of the specified column family of the DB.
|
ColumnFamilyHandle |
getDefaultColumnFamily()
Gets the handle for the default column family
|
Env |
getEnv()
Get the Env object from the DB
|
long |
getLatestSequenceNumber()
The sequence number of the most recent transaction.
|
RocksDB.LiveFiles |
getLiveFiles()
Retrieve the list of all files in the database after flushing the memtable.
|
RocksDB.LiveFiles |
getLiveFiles(boolean flushMemtable)
Retrieve the list of all files in the database.
|
java.util.List<LiveFileMetaData> |
getLiveFilesMetaData()
Gets a list of all table files metadata.
|
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.
|
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.util.Map<java.lang.String,java.lang.String> |
getMapProperty(ColumnFamilyHandle columnFamilyHandle,
java.lang.String property)
Gets a property map.
|
java.util.Map<java.lang.String,java.lang.String> |
getMapProperty(java.lang.String property)
Gets a property map.
|
java.lang.String |
getName()
Get DB name -- the exact same name that was provided as an argument to
as path to
open(Options, String) . |
java.util.Map<java.lang.String,TableProperties> |
getPropertiesOfAllTables()
Get the properties of all tables in the default column family.
|
java.util.Map<java.lang.String,TableProperties> |
getPropertiesOfAllTables(ColumnFamilyHandle columnFamilyHandle)
Get the properties of all tables.
|
java.util.Map<java.lang.String,TableProperties> |
getPropertiesOfTablesInRange(ColumnFamilyHandle columnFamilyHandle,
java.util.List<Range> ranges)
Get the properties of tables in range.
|
java.util.Map<java.lang.String,TableProperties> |
getPropertiesOfTablesInRange(java.util.List<Range> ranges)
Get the properties of tables in range for the default column family.
|
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.
|
Snapshot |
getSnapshot()
Return a handle to the current DB state.
|
java.util.List<LogFile> |
getSortedWalFiles()
Retrieve the sorted list of all wal files with earliest file first.
|
TransactionLogIterator |
getUpdatesSince(long sequenceNumber)
Returns an iterator that is positioned at a write-batch containing
seq_number.
|
void |
ingestExternalFile(ColumnFamilyHandle columnFamilyHandle,
java.util.List<java.lang.String> filePathList,
IngestExternalFileOptions ingestExternalFileOptions)
ingestExternalFile will load a list of external SST files (1) into the DB
We will try to find the lowest possible level that the file can fit in, and
ingest the file into this level (2).
|
void |
ingestExternalFile(java.util.List<java.lang.String> filePathList,
IngestExternalFileOptions ingestExternalFileOptions)
ingestExternalFile will load a list of external SST files (1) into the DB
We will try to find the lowest possible level that the file can fit in, and
ingest the file into this level (2).
|
boolean |
keyMayExist(byte[] key,
int offset,
int len,
java.lang.StringBuilder value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(byte[] key,
java.lang.StringBuilder value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(ColumnFamilyHandle columnFamilyHandle,
byte[] key,
int offset,
int len,
java.lang.StringBuilder 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.StringBuilder value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(ReadOptions readOptions,
byte[] key,
int offset,
int len,
java.lang.StringBuilder value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
boolean |
keyMayExist(ReadOptions readOptions,
byte[] key,
java.lang.StringBuilder 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,
int offset,
int len,
java.lang.StringBuilder 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.StringBuilder value)
If the key definitely does not exist in the database, then this method
returns false, else true.
|
int |
level0StopWriteTrigger()
Number of files in level-0 that would stop writes.
|
int |
level0StopWriteTrigger(ColumnFamilyHandle columnFamilyHandle)
Number of files in level-0 that would stop writes.
|
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.
|
int |
maxMemCompactionLevel()
Maximum level to which a new compacted memtable is pushed if it
does not create overlap.
|
int |
maxMemCompactionLevel(ColumnFamilyHandle columnFamilyHandle)
Maximum level to which a new compacted memtable is pushed if it
does not create overlap.
|
void |
merge(byte[] key,
byte[] value)
Add merge operand for key/value pair.
|
void |
merge(byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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.
|
void |
merge(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpts,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Add merge operand for key/value pair.
|
void |
merge(WriteOptions writeOpts,
byte[] key,
byte[] value)
Add merge operand for key/value pair.
|
void |
merge(WriteOptions writeOpts,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Add merge operand for key/value pair.
|
java.util.Map<byte[],byte[]> |
multiGet(java.util.List<byte[]> keys)
Deprecated.
Consider
multiGetAsList(List) instead. |
java.util.Map<byte[],byte[]> |
multiGet(java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Deprecated.
Consider
multiGetAsList(List, List) instead. |
java.util.Map<byte[],byte[]> |
multiGet(ReadOptions opt,
java.util.List<byte[]> keys)
Deprecated.
Consider
multiGetAsList(ReadOptions, List) instead. |
java.util.Map<byte[],byte[]> |
multiGet(ReadOptions opt,
java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Deprecated.
Consider
multiGetAsList(ReadOptions, List, List)
instead. |
java.util.List<byte[]> |
multiGetAsList(java.util.List<byte[]> keys)
Takes a list of keys, and returns a list of values for the given list of
keys.
|
java.util.List<byte[]> |
multiGetAsList(java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Returns a list of values for the given list of keys.
|
java.util.List<byte[]> |
multiGetAsList(ReadOptions opt,
java.util.List<byte[]> keys)
Returns a list of values for the given list of keys.
|
java.util.List<byte[]> |
multiGetAsList(ReadOptions opt,
java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
java.util.List<byte[]> keys)
Returns a list of values for the given list of keys.
|
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.
|
RocksIterator |
newIterator(ColumnFamilyHandle columnFamilyHandle,
ReadOptions readOptions)
Return a heap-allocated iterator over the contents of the
database.
|
RocksIterator |
newIterator(ReadOptions readOptions)
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.
|
java.util.List<RocksIterator> |
newIterators(java.util.List<ColumnFamilyHandle> columnFamilyHandleList,
ReadOptions readOptions)
Returns iterators from a consistent database state across multiple
column families.
|
int |
numberLevels()
Number of levels used for this DB.
|
int |
numberLevels(ColumnFamilyHandle columnFamilyHandle)
Number of levels used for a column family in this DB.
|
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.
|
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.
|
void |
pauseBackgroundWork()
This function will wait until all currently running background processes
finish.
|
void |
promoteL0(ColumnFamilyHandle columnFamilyHandle,
int targetLevel)
Promote L0.
|
void |
promoteL0(int targetLevel)
Promote L0 for the default column family.
|
void |
put(byte[] key,
byte[] value)
Set the database entry for "key" to "value".
|
void |
put(byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
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.
|
void |
put(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpts,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Set the database entry for "key" to "value" for the specified
column family.
|
void |
put(WriteOptions writeOpts,
byte[] key,
byte[] value)
Set the database entry for "key" to "value".
|
void |
put(WriteOptions writeOpts,
byte[] key,
int offset,
int len,
byte[] value,
int vOffset,
int vLen)
Set the database entry for "key" to "value".
|
void |
releaseSnapshot(Snapshot snapshot)
Release a previously acquired snapshot.
|
void |
remove(byte[] key)
Deprecated.
Use
delete(byte[]) |
void |
remove(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Deprecated.
|
void |
remove(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] key)
Deprecated.
|
void |
remove(WriteOptions writeOpt,
byte[] key)
Deprecated.
|
void |
resetStats()
Reset internal stats for DB and all column families.
|
void |
setDBOptions(MutableDBOptions mutableDBoptions)
Set the options for the column family handle.
|
void |
setOptions(ColumnFamilyHandle columnFamilyHandle,
MutableColumnFamilyOptions mutableColumnFamilyOptions)
Change the options for the column family handle.
|
void |
setOptions(MutableColumnFamilyOptions mutableColumnFamilyOptions)
Change the options for the default column family handle.
|
boolean |
setPreserveDeletesSequenceNumber(long sequenceNumber)
Instructs DB to preserve deletes with sequence numbers >= sequenceNumber.
|
void |
singleDelete(byte[] key)
Remove the database entry for
key . |
void |
singleDelete(ColumnFamilyHandle columnFamilyHandle,
byte[] key)
Remove the database entry for
key . |
void |
singleDelete(ColumnFamilyHandle columnFamilyHandle,
WriteOptions writeOpt,
byte[] key)
Remove the database entry for
key . |
void |
singleDelete(WriteOptions writeOpt,
byte[] key)
Remove the database entry for
key . |
void |
startTrace(TraceOptions traceOptions,
AbstractTraceWriter traceWriter)
Trace DB operations.
|
protected void |
storeOptionsInstance(DBOptionsInterface options) |
Range |
suggestCompactRange()
Suggest the range to compact for the default column family.
|
Range |
suggestCompactRange(ColumnFamilyHandle columnFamilyHandle)
Suggest the range to compact.
|
void |
syncWal()
Sync the WAL.
|
void |
verifyChecksum()
Verify checksum
|
void |
write(WriteOptions writeOpts,
WriteBatch updates)
Apply the specified updates to the database.
|
void |
write(WriteOptions writeOpts,
WriteBatchWithIndex updates)
Apply the specified updates to the database.
|
disposeInternal
disOwnNativeHandle, isOwningHandle
dispose, finalize
public static final byte[] DEFAULT_COLUMN_FAMILY
public static final int NOT_FOUND
protected DBOptionsInterface options_
protected RocksDB(long nativeHandle)
nativeHandle
- The native handle of the C++ RocksDB objectpublic 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 void closeE() throws RocksDBException
close()
except that it
throws an exception if any error occurs.
This will not fsync the WAL files.
If syncing is required, the caller must first call syncWal()
or write(WriteOptions, WriteBatch)
using an empty write batch
with WriteOptions.setSync(boolean)
set to true.
See also close()
.RocksDBException
- if an error occurs whilst closing.public void close()
closeE()
except that it
silently ignores any errors.
This will not fsync the WAL files.
If syncing is required, the caller must first call syncWal()
or write(WriteOptions, WriteBatch)
using an empty write batch
with WriteOptions.setSync(boolean)
set to true.
See also close()
.close
in interface java.lang.AutoCloseable
close
in class AbstractImmutableNativeReference
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.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 java.util.List<ColumnFamilyHandle> createColumnFamilies(ColumnFamilyOptions columnFamilyOptions, java.util.List<byte[]> columnFamilyNames) throws RocksDBException
columnFamilyOptions
- the options for the column families.columnFamilyNames
- the names of the column families.RocksDBException
public java.util.List<ColumnFamilyHandle> createColumnFamilies(java.util.List<ColumnFamilyDescriptor> columnFamilyDescriptors) throws RocksDBException
columnFamilyDescriptors
- the descriptions of the column families.RocksDBException
public void dropColumnFamily(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
columnFamilyHandle
. This call
only records a drop record in the manifest and prevents the column
family from flushing and compacting.columnFamilyHandle
- ColumnFamilyHandle
instanceRocksDBException
- thrown if error happens in underlying
native library.public void dropColumnFamilies(java.util.List<ColumnFamilyHandle> columnFamilies) throws RocksDBException
RocksDBException
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(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
key
- The specified key to be insertedoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value associated with the specified keyvOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if errors happens in underlying native
library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- The specified key to be insertedoffset
- the offset of the "key" array to be used, must
be non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value associated with the specified keyvOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if errors happens in underlying native
library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
writeOpts
- WriteOptions
instance.key
- The specified key to be insertedoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value associated with the specified keyvOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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 void put(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpts
- WriteOptions
instance.key
- The specified key to be insertedoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value associated with the specified keyvOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of bounds@Deprecated public void remove(byte[] key) throws RocksDBException
delete(byte[])
key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(byte[] key) throws RocksDBException
key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(byte[] key, int offset, int len) throws RocksDBException
key
- Key to delete within databaseoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be
non-negative and no larger than ("key".length - offset)RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public void remove(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
delete(ColumnFamilyHandle, byte[])
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- Key to delete within databaseoffset
- the offset of the "key" array to be used,
must be non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public void remove(WriteOptions writeOpt, byte[] key) throws RocksDBException
delete(WriteOptions, byte[])
writeOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(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 delete(WriteOptions writeOpt, byte[] key, int offset, int len) throws RocksDBException
writeOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be
non-negative and no larger than ("key".length - offset)RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public void remove(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) throws RocksDBException
delete(ColumnFamilyHandle, WriteOptions, byte[])
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void delete(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 void delete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key, int offset, int len) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpt
- WriteOptions to be used with delete operationkey
- Key to delete within databaseoffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be
non-negative and no larger than ("key".length - offset)RocksDBException
- thrown if error happens in underlying
native library.@Experimental(value="Performance optimization for a very specific workload") public void singleDelete(byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.key
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.@Experimental(value="Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.columnFamilyHandle
- The column family to delete the key fromkey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.@Experimental(value="Performance optimization for a very specific workload") public void singleDelete(WriteOptions writeOpt, byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.
Note: consider setting WriteOptions.setSync(boolean)
true.writeOpt
- Write options for the deletekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.@Experimental(value="Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) throws RocksDBException
key
. Requires that the key exists
and was not overwritten. It is not an error if the key did not exist
in the database.
If a key is overwritten (by calling put(byte[], byte[])
multiple
times), then the result of calling SingleDelete() on this key is undefined.
SingleDelete() only behaves correctly if there has been only one Put()
for this key since the previous call to SingleDelete() for this key.
This feature is currently an experimental performance optimization
for a very specific workload. It is up to the caller to ensure that
SingleDelete is only used for a key that is not deleted using Delete() or
written using Merge(). Mixing SingleDelete operations with Deletes and
Merges can result in undefined behavior.
Note: consider setting WriteOptions.setSync(boolean)
true.columnFamilyHandle
- The column family to delete the key fromwriteOpt
- Write options for the deletekey
- Key to delete within databaseRocksDBException
- thrown if error happens in underlying
native library.public void deleteRange(byte[] beginKey, byte[] endKey) throws RocksDBException
beginKey
- First key to delete within database (inclusive)endKey
- Last key to delete within database (exclusive)RocksDBException
- thrown if error happens in underlying native
library.public void deleteRange(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancebeginKey
- First key to delete within database (inclusive)endKey
- Last key to delete within database (exclusive)RocksDBException
- thrown if error happens in underlying native
library.public void deleteRange(WriteOptions writeOpt, byte[] beginKey, byte[] endKey) throws RocksDBException
writeOpt
- WriteOptions to be used with delete operationbeginKey
- First key to delete within database (inclusive)endKey
- Last key to delete within database (exclusive)RocksDBException
- thrown if error happens in underlying
native library.public void deleteRange(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] beginKey, byte[] endKey) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpt
- WriteOptions to be used with delete operationbeginKey
- First key to delete within database (included)endKey
- Last key to delete within database (excluded)RocksDBException
- 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(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
key
- the specified key to be merged.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value to be merged with the current value for the
specified key.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and must be non-negative and no larger than
("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the specified key to be merged.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value to be merged with the current value for
the specified key.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
must be non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
writeOpts
- WriteOptions
for this write.key
- the specified key to be merged.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("value".length - offset)value
- the value to be merged with the current value for
the specified key.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic 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 void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancewriteOpts
- WriteOptions
for this write.key
- the specified key to be merged.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the value to be merged with the current value for
the specified key.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)RocksDBException
- thrown if error happens in underlying
native library.java.lang.IndexOutOfBoundsException
- if an offset or length is out of boundspublic void write(WriteOptions writeOpts, WriteBatch updates) throws RocksDBException
writeOpts
- WriteOptions instanceupdates
- WriteBatch instanceRocksDBException
- thrown if error happens in underlying
native library.public void write(WriteOptions writeOpts, WriteBatchWithIndex updates) throws RocksDBException
writeOpts
- WriteOptions instanceupdates
- WriteBatchWithIndex instanceRocksDBException
- 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(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
key
- the key to retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the out-value to receive the retrieved value.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "value".lengthvLen
- the length of the "value" array to be used, must be
non-negative and and no larger than ("value".length - offset)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(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException, java.lang.IllegalArgumentException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key to retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
an no larger than ("key".length - offset)value
- the out-value to receive the retrieved value.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)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(ReadOptions opt, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
opt
- ReadOptions
instance.key
- the key to retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)value
- the out-value to receive the retrieved value.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, must be
non-negative and no larger than ("value".length - offset)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 int get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instanceopt
- ReadOptions
instance.key
- the key to retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be
non-negative and and no larger than ("key".length - offset)value
- the out-value to receive the retrieved value.vOffset
- the offset of the "value" array to be used, must be
non-negative and no longer than "key".lengthvLen
- the length of the "value" array to be used, and must be
non-negative and no larger than ("value".length - offset)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(byte[] key, int offset, int len) throws RocksDBException
key
- the key retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)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(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)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(ReadOptions opt, byte[] key, int offset, int len) throws RocksDBException
key
- the key retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)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 byte[] get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, int offset, int len) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- the key retrieve the value.offset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than ("key".length - offset)opt
- Read options.RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public java.util.Map<byte[],byte[]> multiGet(java.util.List<byte[]> keys) throws RocksDBException
multiGetAsList(List)
instead.keys
- List of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public java.util.Map<byte[],byte[]> multiGet(java.util.List<ColumnFamilyHandle> columnFamilyHandleList, java.util.List<byte[]> keys) throws RocksDBException, java.lang.IllegalArgumentException
multiGetAsList(List, List)
instead.
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.@Deprecated public java.util.Map<byte[],byte[]> multiGet(ReadOptions opt, java.util.List<byte[]> keys) throws RocksDBException
multiGetAsList(ReadOptions, List)
instead.opt
- Read options.keys
- of keys for which values need to be retrieved.RocksDBException
- thrown if error happens in underlying
native library.@Deprecated public java.util.Map<byte[],byte[]> multiGet(ReadOptions opt, java.util.List<ColumnFamilyHandle> columnFamilyHandleList, java.util.List<byte[]> keys) throws RocksDBException
multiGetAsList(ReadOptions, List, List)
instead.
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 java.util.List<byte[]> multiGetAsList(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.List<byte[]> multiGetAsList(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.List<byte[]> multiGetAsList(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.List<byte[]> multiGetAsList(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 boolean keyMayExist(byte[] key, java.lang.StringBuilder value)
key
- byte array of a key to search forvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(byte[] key, int offset, int len, java.lang.StringBuilder value)
key
- byte array of a key to search foroffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than "key".lengthvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, java.lang.StringBuilder value)
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search forvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, java.lang.StringBuilder value)
columnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search foroffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than "key".lengthvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ReadOptions readOptions, byte[] key, java.lang.StringBuilder value)
readOptions
- ReadOptions
instancekey
- byte array of a key to search forvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ReadOptions readOptions, byte[] key, int offset, int len, java.lang.StringBuilder value)
readOptions
- ReadOptions
instancekey
- byte array of a key to search foroffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than "key".lengthvalue
- StringBuilder 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.StringBuilder value)
readOptions
- ReadOptions
instancecolumnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search forvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public boolean keyMayExist(ReadOptions readOptions, ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, java.lang.StringBuilder value)
readOptions
- ReadOptions
instancecolumnFamilyHandle
- ColumnFamilyHandle
instancekey
- byte array of a key to search foroffset
- the offset of the "key" array to be used, must be
non-negative and no larger than "key".lengthlen
- the length of the "key" array to be used, must be non-negative
and no larger than "key".lengthvalue
- StringBuilder instance which is a out parameter if a value is
found in block-cache.public RocksIterator newIterator()
Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).
Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.
public RocksIterator newIterator(ReadOptions readOptions)
Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).
Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.
readOptions
- ReadOptions
instance.public RocksIterator newIterator(ColumnFamilyHandle columnFamilyHandle)
Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).
Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.
columnFamilyHandle
- ColumnFamilyHandle
instancepublic RocksIterator newIterator(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions)
Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).
Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.
columnFamilyHandle
- ColumnFamilyHandle
instancereadOptions
- ReadOptions
instance.public 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 java.util.List<RocksIterator> newIterators(java.util.List<ColumnFamilyHandle> columnFamilyHandleList, ReadOptions readOptions) throws RocksDBException
columnFamilyHandleList
- List
containing
ColumnFamilyHandle
instances.readOptions
- ReadOptions
instance.List
containing RocksIterator
instancesRocksDBException
- thrown if error happens in underlying
native library.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 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
instance, or null for the default column family.property
- 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 java.util.Map<java.lang.String,java.lang.String> getMapProperty(java.lang.String property) throws RocksDBException
property
- to be fetched.RocksDBException
- if an error happens in the underlying native code.public java.util.Map<java.lang.String,java.lang.String> getMapProperty(ColumnFamilyHandle columnFamilyHandle, java.lang.String property) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column family.property
- to be fetched.RocksDBException
- if an error happens in the underlying native code.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
java.math.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
java.math.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
instance, or null for the default column familyproperty
- to be fetched.RocksDBException
- if an error happens in the underlying native code.public void resetStats() throws RocksDBException
Options.statistics()
as it is not
owned by DB.RocksDBException
public long getAggregatedLongProperty(java.lang.String property) throws RocksDBException
Return sum of the getLongProperty of all the column families
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
java.math.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[] getApproximateSizes(ColumnFamilyHandle columnFamilyHandle, java.util.List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags)
sizeApproximationFlags
defines whether the returned size
should include the recently written data in the mem-tables (if
the mem-table type supports it), data serialized to disk, or both.columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column familyranges
- the ranges over which to approximate sizessizeApproximationFlags
- flags to determine what to include in the
approximation.public long[] getApproximateSizes(java.util.List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags)
sizeApproximationFlags
defines whether the returned size
should include the recently written data in the mem-tables (if
the mem-table type supports it), data serialized to disk, or both.ranges
- the ranges over which to approximate sizessizeApproximationFlags
- flags to determine what to include in the
approximation.public RocksDB.CountAndSize getApproximateMemTableStats(ColumnFamilyHandle columnFamilyHandle, Range range)
getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...)
,
except that it returns approximate number of records and size in memtables.columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column familyrange
- the ranges over which to get the memtable statspublic RocksDB.CountAndSize getApproximateMemTableStats(Range range)
getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...)
,
except that it returns approximate number of records and size in memtables.range
- the ranges over which to get the memtable statspublic void compactRange() throws RocksDBException
Range compaction of database.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
See also
RocksDBException
- thrown if an error occurs within the native
part of the library.public void compactRange(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
Range compaction of column family.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
See also
columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column family.RocksDBException
- thrown if an error occurs within the native
part of the library.public void compactRange(byte[] begin, byte[] end) throws RocksDBException
Range compaction of database.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
See also
begin
- start of key range (included in range)end
- end of key range (excluded from range)RocksDBException
- thrown if an error occurs within the native
part of the library.public void compactRange(ColumnFamilyHandle columnFamilyHandle, byte[] begin, byte[] end) throws RocksDBException
Range compaction of column family.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
See also
columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column family.begin
- start of key range (included in range)end
- end of key range (excluded from range)RocksDBException
- thrown if an error occurs within the native
part of the library.@Deprecated public void compactRange(boolean changeLevel, int targetLevel, int targetPathId) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)
insteadRange compaction of database.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
Compaction outputs should be placed in options.db_paths [target_path_id]. Behavior is undefined if target_path_id is out of range.
See also
changeLevel
- reduce level after compactiontargetLevel
- target level to compact totargetPathId
- the target path id of output pathRocksDBException
- thrown if an error occurs within the native
part of the library.@Deprecated public void compactRange(ColumnFamilyHandle columnFamilyHandle, boolean changeLevel, int targetLevel, int targetPathId) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)
insteadRange compaction of column family.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
Compaction outputs should be placed in options.db_paths [target_path_id]. Behavior is undefined if target_path_id is out of range.
See also
columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column family.changeLevel
- reduce level after compactiontargetLevel
- target level to compact totargetPathId
- the target path id of output pathRocksDBException
- thrown if an error occurs within the native
part of the library.@Deprecated public void compactRange(byte[] begin, byte[] end, boolean changeLevel, int targetLevel, int targetPathId) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)
insteadRange compaction of database.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
Compaction outputs should be placed in options.db_paths [target_path_id]. Behavior is undefined if target_path_id is out of range.
See also
begin
- start of key range (included in range)end
- end of key range (excluded from range)changeLevel
- reduce level after compactiontargetLevel
- target level to compact totargetPathId
- the target path id of output pathRocksDBException
- thrown if an error occurs within the native
part of the library.@Deprecated public void compactRange(ColumnFamilyHandle columnFamilyHandle, byte[] begin, byte[] end, boolean changeLevel, int targetLevel, int targetPathId) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[], CompactRangeOptions)
insteadRange compaction of column family.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
Compaction outputs should be placed in options.db_paths [target_path_id]. Behavior is undefined if target_path_id is out of range.
See also
columnFamilyHandle
- ColumnFamilyHandle
instance.begin
- start of key range (included in range)end
- end of key range (excluded from range)changeLevel
- reduce level after compactiontargetLevel
- target level to compact totargetPathId
- the target path id of output pathRocksDBException
- thrown if an error occurs within the native
part of the library.public void compactRange(ColumnFamilyHandle columnFamilyHandle, byte[] begin, byte[] end, CompactRangeOptions compactRangeOptions) throws RocksDBException
Range compaction of column family.
Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.
columnFamilyHandle
- ColumnFamilyHandle
instance.begin
- start of key range (included in range)end
- end of key range (excluded from range)compactRangeOptions
- options for the compactionRocksDBException
- thrown if an error occurs within the native
part of the library.public void setOptions(ColumnFamilyHandle columnFamilyHandle, MutableColumnFamilyOptions mutableColumnFamilyOptions) throws RocksDBException
columnFamilyHandle
- ColumnFamilyHandle
instance, or null for the default column family.mutableColumnFamilyOptions
- the options.RocksDBException
public void setOptions(MutableColumnFamilyOptions mutableColumnFamilyOptions) throws RocksDBException
mutableColumnFamilyOptions
- the options.RocksDBException
public void setDBOptions(MutableDBOptions mutableDBoptions) throws RocksDBException
mutableDBoptions
- the options.RocksDBException
public java.util.List<java.lang.String> compactFiles(CompactionOptions compactionOptions, java.util.List<java.lang.String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[])
in that CompactFiles() performs the compaction job using the CURRENT
thread.compactionOptions
- compaction optionsinputFileNames
- the name of the files to compactoutputLevel
- the level to which they should be compactedoutputPathId
- the id of the output path, or -1compactionJobInfo
- the compaction job info, this parameter
will be updated with the info from compacting the files,
can just be null if you don't need it.RocksDBException
public java.util.List<java.lang.String> compactFiles(CompactionOptions compactionOptions, ColumnFamilyHandle columnFamilyHandle, java.util.List<java.lang.String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) throws RocksDBException
compactRange(ColumnFamilyHandle, byte[], byte[])
in that CompactFiles() performs the compaction job using the CURRENT
thread.compactionOptions
- compaction optionscolumnFamilyHandle
- columnFamilyHandle, or null for the
default column familyinputFileNames
- the name of the files to compactoutputLevel
- the level to which they should be compactedoutputPathId
- the id of the output path, or -1compactionJobInfo
- the compaction job info, this parameter
will be updated with the info from compacting the files,
can just be null if you don't need it.RocksDBException
public void pauseBackgroundWork() throws RocksDBException
continueBackgroundWork()
is calledRocksDBException
- If an error occurs when pausing background workpublic void continueBackgroundWork() throws RocksDBException
pauseBackgroundWork()
RocksDBException
- If an error occurs when resuming background workpublic void enableAutoCompaction(java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
ColumnFamilyOptions.disableAutoCompactions()
option for each
column family to false, after which it will schedule a flush/compaction.
NOTE: Setting disableAutoCompactions to 'false' through
setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)
does NOT schedule a flush/compaction afterwards, and only changes the
parameter itself within the column family option.columnFamilyHandles
- the column family handlesRocksDBException
public int numberLevels()
public int numberLevels(ColumnFamilyHandle columnFamilyHandle)
columnFamilyHandle
- the column family handle, or null
for the default column familypublic int maxMemCompactionLevel()
public int maxMemCompactionLevel(ColumnFamilyHandle columnFamilyHandle)
columnFamilyHandle
- the column family handlepublic int level0StopWriteTrigger()
public int level0StopWriteTrigger(ColumnFamilyHandle columnFamilyHandle)
columnFamilyHandle
- the column family handlepublic java.lang.String getName()
open(Options, String)
.public Env getEnv()
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.public void flush(FlushOptions flushOptions, java.util.List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException
flush(FlushOptions, ColumnFamilyHandle)
multiple times.
If atomic flush is enabled, this will flush all column families
specified up to the latest sequence number at the time when flush is
requested.flushOptions
- FlushOptions
instance.columnFamilyHandles
- column family handles.RocksDBException
- thrown if an error occurs within the native
part of the library.public void flushWal(boolean sync) throws RocksDBException
sync
is true,
it calls syncWal()
afterwards.sync
- true to also fsync to disk.RocksDBException
public void syncWal() throws RocksDBException
write(WriteOptions, WriteBatch)
followed by
syncWal()
is not exactly the same as
write(WriteOptions, WriteBatch)
with
WriteOptions.sync()
set to true; In the latter case the changes
won't be visible until the sync is done.
Currently only works if Options.allowMmapWrites()
is set to false.RocksDBException
public long getLatestSequenceNumber()
The sequence number of the most recent transaction.
public boolean setPreserveDeletesSequenceNumber(long sequenceNumber)
sequenceNumber
- the minimum sequence number to preservepublic void disableFileDeletions() throws RocksDBException
Prevent file deletions. Compactions will continue to occur, but no obsolete files will be deleted. Calling this multiple times have the same effect as calling it once.
RocksDBException
- thrown if operation was not performed
successfully.public void enableFileDeletions(boolean force) throws RocksDBException
Allow compactions to delete obsolete files. If force == true, the call to EnableFileDeletions() will guarantee that file deletions are enabled after the call, even if DisableFileDeletions() was called multiple times before.
If force == false, EnableFileDeletions will only enable file deletion after it's been called at least as many times as DisableFileDeletions(), enabling the two methods to be called by two threads concurrently without synchronization -- i.e., file deletions will be enabled only after both threads call EnableFileDeletions()
force
- boolean value described above.RocksDBException
- thrown if operation was not performed
successfully.public RocksDB.LiveFiles getLiveFiles() throws RocksDBException
getLiveFiles(boolean)
.RocksDBException
public RocksDB.LiveFiles getLiveFiles(boolean flushMemtable) throws RocksDBException
flushMemtable
is true, you still need to call getSortedWalFiles()
after getLiveFiles(boolean)
to compensate for new data that
arrived to already-flushed column families while other column families
were flushing.
NOTE: Calling getLiveFiles(boolean)
followed by
getSortedWalFiles()
can generate a lossless backup.flushMemtable
- set to true to flush before recoding the live
files. Setting to false is useful when we don't want to wait for flush
which may have to wait for compaction to complete taking an
indeterminate time.RocksDBException
public java.util.List<LogFile> getSortedWalFiles() throws RocksDBException
RocksDBException
public TransactionLogIterator getUpdatesSince(long sequenceNumber) throws RocksDBException
Returns an iterator that is positioned at a write-batch containing seq_number. If the sequence number is non existent, it returns an iterator at the first available seq_no after the requested seq_no.
Must set WAL_ttl_seconds or WAL_size_limit_MB to large values to use this api, else the WAL files will get cleared aggressively and the iterator might keep getting invalid before an update is read.
sequenceNumber
- sequence number offsetTransactionLogIterator
instance.RocksDBException
- if iterator cannot be retrieved
from native-side.public void deleteFile(java.lang.String name) throws RocksDBException
name
- the file nameRocksDBException
public java.util.List<LiveFileMetaData> getLiveFilesMetaData()
public ColumnFamilyMetaData getColumnFamilyMetaData(ColumnFamilyHandle columnFamilyHandle)
columnFamilyHandle
- the column familypublic ColumnFamilyMetaData GetColumnFamilyMetaData()
public void ingestExternalFile(java.util.List<java.lang.String> filePathList, IngestExternalFileOptions ingestExternalFileOptions) throws RocksDBException
SstFileWriter
(2) We will try to ingest the files to the lowest possible level
even if the file compression doesn't match the level compressionfilePathList
- The list of files to ingestingestExternalFileOptions
- the options for the ingestionRocksDBException
- thrown if error happens in underlying
native library.public void ingestExternalFile(ColumnFamilyHandle columnFamilyHandle, java.util.List<java.lang.String> filePathList, IngestExternalFileOptions ingestExternalFileOptions) throws RocksDBException
SstFileWriter
(2) We will try to ingest the files to the lowest possible level
even if the file compression doesn't match the level compressioncolumnFamilyHandle
- The column family for the ingested filesfilePathList
- The list of files to ingestingestExternalFileOptions
- the options for the ingestionRocksDBException
- thrown if error happens in underlying
native library.public void verifyChecksum() throws RocksDBException
RocksDBException
- if the checksum is not validpublic ColumnFamilyHandle getDefaultColumnFamily()
public java.util.Map<java.lang.String,TableProperties> getPropertiesOfAllTables(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
columnFamilyHandle
- the column family handle, or null for the default
column family.RocksDBException
public java.util.Map<java.lang.String,TableProperties> getPropertiesOfAllTables() throws RocksDBException
RocksDBException
public java.util.Map<java.lang.String,TableProperties> getPropertiesOfTablesInRange(ColumnFamilyHandle columnFamilyHandle, java.util.List<Range> ranges) throws RocksDBException
columnFamilyHandle
- the column family handle, or null for the default
column family.ranges
- the ranges over which to get the table propertiesRocksDBException
public java.util.Map<java.lang.String,TableProperties> getPropertiesOfTablesInRange(java.util.List<Range> ranges) throws RocksDBException
ranges
- the ranges over which to get the table propertiesRocksDBException
public Range suggestCompactRange(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
columnFamilyHandle
- the column family handle, or null for the default
column family.RocksDBException
public Range suggestCompactRange() throws RocksDBException
RocksDBException
public void promoteL0(ColumnFamilyHandle columnFamilyHandle, int targetLevel) throws RocksDBException
columnFamilyHandle
- the column family handle,
or null for the default column family.RocksDBException
public void promoteL0(int targetLevel) throws RocksDBException
RocksDBException
public void startTrace(TraceOptions traceOptions, AbstractTraceWriter traceWriter) throws RocksDBException
endTrace()
to stop tracing.traceOptions
- the optionstraceWriter
- the trace writerRocksDBException
public void endTrace() throws RocksDBException
startTrace(TraceOptions, AbstractTraceWriter)
RocksDBException
public static void destroyDB(java.lang.String path, Options options) throws RocksDBException
path
- the path to the Rocksdb database.options
- Options
instance.RocksDBException
- thrown if error happens in underlying
native library.protected void storeOptionsInstance(DBOptionsInterface options)
protected void disposeInternal(long handle)
disposeInternal
in class RocksObject