Class RocksDB
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
OptimisticTransactionDB,TransactionDB,TtlDB
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]static final intprotected DBOptionsInterface<?> Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelAllBackgroundWork(boolean wait) This function will cancel all currently running background processes.voidclipColumnFamily(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) ClipColumnFamily() will clip the entries in the CF according to the range [begin_key, end_key).voidclose()This is similar tocloseE()except that it silently ignores any errors.voidcloseE()This is similar toclose()except that it throws an exception if any error occurs.compactFiles(CompactionOptions compactionOptions, List<String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) Takes a list of files specified by file names and compacts them to the specified level.compactFiles(CompactionOptions compactionOptions, ColumnFamilyHandle columnFamilyHandle, List<String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) Takes a list of files specified by file names and compacts them to the specified level.voidRange compaction of database.voidcompactRange(byte[] begin, byte[] end) Range compaction of database.voidcompactRange(ColumnFamilyHandle columnFamilyHandle) Range compaction of column family.voidcompactRange(ColumnFamilyHandle columnFamilyHandle, byte[] begin, byte[] end) Range compaction of column family.voidcompactRange(ColumnFamilyHandle columnFamilyHandle, byte[] begin, byte[] end, CompactRangeOptions compactRangeOptions) Range compaction of column family.voidResumes background work which was suspended by previously callingpauseBackgroundWork()createColumnFamilies(List<ColumnFamilyDescriptor> columnFamilyDescriptors) Bulk create column families with the same column family options.createColumnFamilies(ColumnFamilyOptions columnFamilyOptions, List<byte[]> columnFamilyNames) Bulk create column families with the same column family options.createColumnFamily(ColumnFamilyDescriptor columnFamilyDescriptor) Creates a new column family with the name columnFamilyName and allocates a ColumnFamilyHandle within an internal structure.createColumnFamilyWithImport(ColumnFamilyDescriptor columnFamilyDescriptor, ImportColumnFamilyOptions importColumnFamilyOptions, List<ExportImportFilesMetaData> metadatas) createColumnFamilyWithImport(ColumnFamilyDescriptor columnFamilyDescriptor, ImportColumnFamilyOptions importColumnFamilyOptions, ExportImportFilesMetaData metadata) Creates a new column family with the name columnFamilyName and import external SST files specified in `metadata` allocates a ColumnFamilyHandle within an internal structure.voiddelete(byte[] key) Delete the database entry (if any) for "key".voiddelete(byte[] key, int offset, int len) Delete the database entry (if any) for "key".voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) Delete the database entry (if any) for "key".voiddelete(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) Delete the database entry (if any) for "key".voiddelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) Delete the database entry (if any) for "key".voiddelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key, int offset, int len) Delete the database entry (if any) for "key".voiddelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, ByteBuffer key) Delete the database entry (if any) for "key".voiddelete(WriteOptions writeOpt, byte[] key) Delete the database entry (if any) for "key".voiddelete(WriteOptions writeOpt, byte[] key, int offset, int len) Delete the database entry (if any) for "key".voiddelete(WriteOptions writeOpt, ByteBuffer key) Delete the database entry (if any) for "key".voiddeleteFile(String name) Delete the file name from the db directory and update the internal state to reflect that.voiddeleteFilesInRanges(ColumnFamilyHandle columnFamily, List<byte[]> ranges, boolean includeEnd) Delete files in multiple ranges at once.voiddeleteRange(byte[] beginKey, byte[] endKey) Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey".voiddeleteRange(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey".voiddeleteRange(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] beginKey, byte[] endKey) Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey".voiddeleteRange(WriteOptions writeOpt, byte[] beginKey, byte[] endKey) Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey".voiddestroyColumnFamilyHandle(ColumnFamilyHandle columnFamilyHandle) Deletes native column family handle of givenColumnFamilyHandleJava object and removes reference fromownedColumnFamilyHandles.static voidStatic method to destroy the contents of the specified database.voidPrevent file deletions.protected voiddisposeInternal(long handle) voiddropColumnFamilies(List<ColumnFamilyHandle> columnFamilies) voiddropColumnFamily(ColumnFamilyHandle columnFamilyHandle) Drops the column family specified bycolumnFamilyHandle.voidenableAutoCompaction(List<ColumnFamilyHandle> columnFamilyHandles) Enable automatic compactions for the given column families if they were previously disabled.voidEnableFileDeletions 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()voidendTrace()Stop tracing DB operations.voidflush(FlushOptions flushOptions) Flush all memory table data.voidflush(FlushOptions flushOptions, List<ColumnFamilyHandle> columnFamilyHandles) Flushes multiple column families.voidflush(FlushOptions flushOptions, ColumnFamilyHandle columnFamilyHandle) Flush all memory table data.voidflushWal(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.intget(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.intget(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.intget(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.intget(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.intget(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.intget(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.intget(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, ByteBuffer key, ByteBuffer value) 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.intget(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.intget(ReadOptions opt, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Get the value associated with the specified key.intget(ReadOptions opt, ByteBuffer key, ByteBuffer value) Get the value associated with the specified key within column family.longgetAggregatedLongProperty(String property) Return sum of the getLongProperty of all the column familiesgetApproximateMemTableStats(ColumnFamilyHandle columnFamilyHandle, Range range) This method is similar togetApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.getApproximateMemTableStats(Range range) This method is similar togetApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.long[]getApproximateSizes(List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags) Get the approximate file system space used by keys in each range for the default column family.long[]getApproximateSizes(ColumnFamilyHandle columnFamilyHandle, List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags) Get the approximate file system space used by keys in each range.Obtains the meta data of the default column family of the DB.getColumnFamilyMetaData(ColumnFamilyHandle columnFamilyHandle) Obtains the meta data of the specified column family of the DB.Get the database optionsGets the handle for the default column familygetEnv()Get the Env object from the DBlongThe sequence number of the most recent transaction.Retrieve the list of all files in the database after flushing the memtable.getLiveFiles(boolean flushMemtable) Retrieve the list of all files in the database.Gets a list of all table files metadata.longgetLongProperty(String property) Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value.longgetLongProperty(ColumnFamilyHandle columnFamilyHandle, String property) Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value.getMapProperty(String property) Gets a property map.getMapProperty(ColumnFamilyHandle columnFamilyHandle, String property) Gets a property map.getName()Get DB name -- the exact same name that was provided as an argument to as path toopen(Options, String).Default column family optionsgetOptions(ColumnFamilyHandle columnFamilyHandle) Get the options for the column family handleReturn perf context bound to this thread.Return current performance level measurement settings.Get the properties of all tables in the default column family.getPropertiesOfAllTables(ColumnFamilyHandle columnFamilyHandle) Get the properties of all tables.getPropertiesOfTablesInRange(List<Range> ranges) Get the properties of tables in range for the default column family.getPropertiesOfTablesInRange(ColumnFamilyHandle columnFamilyHandle, List<Range> ranges) Get the properties of tables in range.getProperty(String property) DB implementations can export properties about their state via this method.getProperty(ColumnFamilyHandle columnFamilyHandle, String property) DB implements can export properties about their state via this method on a per column family level.Return a handle to the current DB state.Retrieve the sorted list of all wal files with earliest file first.getUpdatesSince(long sequenceNumber) Returns an iterator that is positioned at a write-batch containing seq_number.voidingestExternalFile(List<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).voidingestExternalFile(ColumnFamilyHandle columnFamilyHandle, List<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).booleanisClosed()booleankeyExists(byte[] key) Check if a key exists in the database.booleankeyExists(byte[] key, int offset, int len) Check if a key exists in the database.booleankeyExists(ByteBuffer key) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, byte[] key) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, int offset, int len) Check if a key exists in the database.booleankeyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key) Check if a key exists in the database.booleankeyExists(ReadOptions readOptions, byte[] key) Check if a key exists in the database.booleankeyExists(ReadOptions readOptions, byte[] key, int offset, int len) Check if a key exists in the database.booleankeyExists(ReadOptions readOptions, ByteBuffer key) Check if a key exists in the database.booleankeyMayExist(byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ByteBuffer key) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.keyMayExist(ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.keyMayExist(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.keyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue.booleankeyMayExist(ReadOptions readOptions, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ReadOptions readOptions, byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.booleankeyMayExist(ReadOptions readOptions, ByteBuffer key) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist.keyMayExist(ReadOptions readOptions, ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue.intNumber of files in level-0 that would stop writes.intlevel0StopWriteTrigger(ColumnFamilyHandle columnFamilyHandle) Number of files in level-0 that would stop writes.static List<byte[]> listColumnFamilies(Options options, String path) Static method to determine all available column families for a rocksdb database identified by pathstatic voidLoads the necessary library files.static voidloadLibrary(List<String> paths) Tries to load the necessary library files from the given list of directories.protected ColumnFamilyHandleCreate a handle for the default CF on openintMaximum level to which a new compacted memtable is pushed if it does not create overlap.intmaxMemCompactionLevel(ColumnFamilyHandle columnFamilyHandle) Maximum level to which a new compacted memtable is pushed if it does not create overlap.voidmerge(byte[] key, byte[] value) Add merge operand for key/value pair.voidmerge(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Add merge operand for key/value pair.voidmerge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) Add merge operand for key/value pair in a ColumnFamily.voidmerge(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Add merge operand for key/value pair in a ColumnFamily.voidmerge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) Add merge operand for key/value pair.voidmerge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Add merge operand for key/value pair.voidmerge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) voidmerge(WriteOptions writeOpts, byte[] key, byte[] value) Add merge operand for key/value pair.voidmerge(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Add merge operand for key/value pair.voidmerge(WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) List<byte[]> multiGetAsList(List<byte[]> keys) Takes a list of keys, and returns a list of values for the given list of keys.List<byte[]> multiGetAsList(List<ColumnFamilyHandle> columnFamilyHandleList, List<byte[]> keys) Returns a list of values for the given list of keys.List<byte[]> multiGetAsList(ReadOptions opt, List<byte[]> keys) Returns a list of values for the given list of keys.List<byte[]> multiGetAsList(ReadOptions opt, List<ColumnFamilyHandle> columnFamilyHandleList, List<byte[]> keys) Returns a list of values for the given list of keys.multiGetByteBuffers(List<ByteBuffer> keys, List<ByteBuffer> values) Fetches a list of values for the given list of keys, all from the default column family.multiGetByteBuffers(List<ColumnFamilyHandle> columnFamilyHandleList, List<ByteBuffer> keys, List<ByteBuffer> values) Fetches a list of values for the given list of keys.multiGetByteBuffers(ReadOptions readOptions, List<ByteBuffer> keys, List<ByteBuffer> values) Fetches a list of values for the given list of keys, all from the default column family.multiGetByteBuffers(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandleList, List<ByteBuffer> keys, List<ByteBuffer> values) Fetches a list of values for the given list of keys.Return a heap-allocated iterator over the contents of the database.newIterator(ColumnFamilyHandle columnFamilyHandle) Return a heap-allocated iterator over the contents of a ColumnFamily.newIterator(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions) Return a heap-allocated iterator over the contents of a ColumnFamily.newIterator(ReadOptions readOptions) Return a heap-allocated iterator over the contents of the database.newIterators(List<ColumnFamilyHandle> columnFamilyHandleList) Returns iterators from a consistent database state across multiple column families.newIterators(List<ColumnFamilyHandle> columnFamilyHandleList, ReadOptions readOptions) Returns iterators from a consistent database state across multiple column families.intNumber of levels used for this DB.intnumberLevels(ColumnFamilyHandle columnFamilyHandle) Number of levels used for a column family in this DB.static RocksDBThe 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 RocksDBopen(String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, 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 RocksDBopen(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, 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 RocksDBThe factory constructor of RocksDB that opens a RocksDB instance given the path to the database using the specified options and db path.static RocksDBopenAsSecondary(DBOptions options, String path, String secondaryPath, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) Open DB as secondary instance with column families.static RocksDBopenAsSecondary(Options options, String path, String secondaryPath) Open DB as secondary instance with only the default column family.static RocksDBopenReadOnly(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 RocksDBopenReadOnly(String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, 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.static RocksDBopenReadOnly(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, 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 RocksDBopenReadOnly(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles, boolean errorIfWalFileExists) 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 RocksDBopenReadOnly(Options options, 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 RocksDBopenReadOnly(Options options, String path, boolean errorIfWalFileExists) 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.voidThis function will wait until all currently running background processes finish.voidpromoteL0(int targetLevel) Promote L0 for the default column family.voidpromoteL0(ColumnFamilyHandle columnFamilyHandle, int targetLevel) Promote L0.voidput(byte[] key, byte[] value) Set the database entry for "key" to "value".voidput(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Set the database entry for "key" to "value".voidput(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) Set the database entry for "key" to "value" in the specified column family.voidput(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.voidput(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) Set the database entry for "key" to "value" for the specified column family.voidput(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.voidput(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) Set the database entry for "key" to "value" for the specified column family.voidput(WriteOptions writeOpts, byte[] key, byte[] value) Set the database entry for "key" to "value".voidput(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) Set the database entry for "key" to "value".voidput(WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) Set the database entry for "key" to "value".voidreleaseSnapshot(Snapshot snapshot) Release a previously acquired snapshot.voidReset internal stats for DB and all column families.static RocksDB.VersionvoidsetDBOptions(MutableDBOptions mutableDBoptions) Set the options for the column family handle.voidsetOptions(ColumnFamilyHandle columnFamilyHandle, MutableColumnFamilyOptions mutableColumnFamilyOptions) Change the options for the column family handle.voidsetOptions(MutableColumnFamilyOptions mutableColumnFamilyOptions) Change the options for the default column family handle.voidsetPerfLevel(PerfLevel level) Set performance level for rocksdb performance measurement.voidsingleDelete(byte[] key) Remove the database entry forkey.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) Remove the database entry forkey.voidsingleDelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) Remove the database entry forkey.voidsingleDelete(WriteOptions writeOpt, byte[] key) Remove the database entry forkey.voidstartTrace(TraceOptions traceOptions, AbstractTraceWriter traceWriter) Trace DB operations.protected voidstoreDefaultColumnFamilyHandle(ColumnFamilyHandle columnFamilyHandle) protected voidstoreOptionsInstance(DBOptionsInterface<?> options) Suggest the range to compact for the default column family.suggestCompactRange(ColumnFamilyHandle columnFamilyHandle) Suggest the range to compact.voidsyncWal()Sync the WAL.voidMake the secondary instance catch up with the primary by tailing and replaying the MANIFEST and WAL of the primary.voidVerify checksumvoidwrite(WriteOptions writeOpts, WriteBatch updates) Apply the specified updates to the database.voidwrite(WriteOptions writeOpts, WriteBatchWithIndex updates) Apply the specified updates to the database.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
disOwnNativeHandle, isOwningHandle
-
Field Details
-
DEFAULT_COLUMN_FAMILY
public static final byte[] DEFAULT_COLUMN_FAMILY -
NOT_FOUND
public static final int NOT_FOUND- See Also:
-
options_
-
-
Constructor Details
-
RocksDB
protected RocksDB(long nativeHandle) Private constructor.- Parameters:
nativeHandle- The native handle of the C++ RocksDB object
-
-
Method Details
-
loadLibrary
public static void loadLibrary()Loads the necessary library files. Calling this method twice will have no effect. By default the method extracts the shared library for loading at java.io.tmpdir, however, you can override this temporary location by setting the environment variable ROCKSDB_SHAREDLIB_DIR. -
loadLibrary
Tries to load the necessary library files from the given list of directories.- Parameters:
paths- a list of strings where each describes a directory of a library.
-
rocksdbVersion
-
isClosed
public boolean isClosed() -
open
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.- Parameters:
path- the path to the rocksdb.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
open
public static RocksDB open(String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException 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.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.
- Parameters:
path- the path to the rocksdb.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
open
The factory constructor of RocksDB that opens a RocksDB instance given the path to the database using the specified options and db path.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.
- Parameters:
options-Optionsinstance.path- the path to the rocksdb.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
open
public static RocksDB open(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException 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.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.
- Parameters:
options-DBOptionsinstance.path- the path to the rocksdb.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
openReadOnly
The factory constructor of RocksDB that opens a RocksDB instance in Read-Only mode given the path to the database using the default options.- Parameters:
path- the path to the RocksDB.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openReadOnly
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.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.
- Parameters:
options-Optionsinstance.path- the path to the RocksDB.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openReadOnly
public static RocksDB openReadOnly(Options options, String path, boolean errorIfWalFileExists) throws RocksDBException 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.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.
- Parameters:
options-Optionsinstance.path- the path to the RocksDB.errorIfWalFileExists- true to raise an error when opening the db if a Write Ahead Log file exists, false otherwise.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openReadOnly
public static RocksDB openReadOnly(String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException The factory constructor of RocksDB that opens a RocksDB instance in Read-Only mode given the path to the database using the default options.- Parameters:
path- the path to the RocksDB.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openReadOnly
public static RocksDB openReadOnly(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException 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.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.
- Parameters:
options-DBOptionsinstance.path- the path to the RocksDB.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openReadOnly
public static RocksDB openReadOnly(DBOptions options, String path, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles, boolean errorIfWalFileExists) throws RocksDBException 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.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.
- Parameters:
options-DBOptionsinstance.path- the path to the RocksDB.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.errorIfWalFileExists- true to raise an error when opening the db if a Write Ahead Log file exists, false otherwise.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openAsSecondary
public static RocksDB openAsSecondary(Options options, String path, String secondaryPath) throws RocksDBException Open DB as secondary instance with only the default column family.The secondary instance can dynamically tail the MANIFEST of a primary that must have already been created. User can call
tryCatchUpWithPrimary()to make the secondary instance catch up with primary (WAL tailing is NOT supported now) whenever the user feels necessary. Column families created by the primary after the secondary instance starts are currently ignored by the secondary instance. Column families opened by secondary and dropped by the primary will be dropped by secondary as well. However the user of the secondary instance can still access the data of such dropped column family as long as they do not destroy the corresponding column family handle. WAL tailing is not supported at present, but will arrive soon.- Parameters:
options- the options to open the secondary instance.path- the path to the primary RocksDB instance.secondaryPath- points to a directory where the secondary instance stores its info log- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
openAsSecondary
public static RocksDB openAsSecondary(DBOptions options, String path, String secondaryPath, List<ColumnFamilyDescriptor> columnFamilyDescriptors, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException Open DB as secondary instance with column families. You can open a subset of column families in secondary mode.The secondary instance can dynamically tail the MANIFEST of a primary that must have already been created. User can call
tryCatchUpWithPrimary()to make the secondary instance catch up with primary (WAL tailing is NOT supported now) whenever the user feels necessary. Column families created by the primary after the secondary instance starts are currently ignored by the secondary instance. Column families opened by secondary and dropped by the primary will be dropped by secondary as well. However the user of the secondary instance can still access the data of such dropped column family as long as they do not destroy the corresponding column family handle. WAL tailing is not supported at present, but will arrive soon.- Parameters:
options- the options to open the secondary instance.path- the path to the primary RocksDB instance.secondaryPath- points to a directory where the secondary instance stores its info log.columnFamilyDescriptors- list of column family descriptorscolumnFamilyHandles- will be filled with ColumnFamilyHandle instances on open.- Returns:
- a
RocksDBinstance on success, null if the specifiedRocksDBcan not be opened. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
closeE
This is similar toclose()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()orwrite(WriteOptions, WriteBatch)using an empty write batch withWriteOptions.setSync(boolean)set to true.See also
close().- Throws:
RocksDBException- if an error occurs whilst closing.
-
close
public void close()This is similar tocloseE()except that it silently ignores any errors.This will not fsync the WAL files. If syncing is required, the caller must first call
syncWal()orwrite(WriteOptions, WriteBatch)using an empty write batch withWriteOptions.setSync(boolean)set to true.See also
close().- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractImmutableNativeReference
-
listColumnFamilies
Static method to determine all available column families for a rocksdb database identified by path- Parameters:
options- Options for opening the databasepath- Absolute path to rocksdb database- Returns:
- List<byte[]> List containing the column family names
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
createColumnFamily
public ColumnFamilyHandle createColumnFamily(ColumnFamilyDescriptor columnFamilyDescriptor) throws RocksDBException Creates a new column family with the name columnFamilyName and allocates a ColumnFamilyHandle within an internal structure. The ColumnFamilyHandle is automatically disposed with DB disposal.- Parameters:
columnFamilyDescriptor- column family to be created.- Returns:
ColumnFamilyHandleinstance.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
createColumnFamilies
public List<ColumnFamilyHandle> createColumnFamilies(ColumnFamilyOptions columnFamilyOptions, List<byte[]> columnFamilyNames) throws RocksDBException Bulk create column families with the same column family options.- Parameters:
columnFamilyOptions- the options for the column families.columnFamilyNames- the names of the column families.- Returns:
- the handles to the newly created column families.
- Throws:
RocksDBException- if an error occurs whilst creating the column families
-
createColumnFamilies
public List<ColumnFamilyHandle> createColumnFamilies(List<ColumnFamilyDescriptor> columnFamilyDescriptors) throws RocksDBException Bulk create column families with the same column family options.- Parameters:
columnFamilyDescriptors- the descriptions of the column families.- Returns:
- the handles to the newly created column families.
- Throws:
RocksDBException- if an error occurs whilst creating the column families
-
createColumnFamilyWithImport
public ColumnFamilyHandle createColumnFamilyWithImport(ColumnFamilyDescriptor columnFamilyDescriptor, ImportColumnFamilyOptions importColumnFamilyOptions, ExportImportFilesMetaData metadata) throws RocksDBException Creates a new column family with the name columnFamilyName and import external SST files specified in `metadata` allocates a ColumnFamilyHandle within an internal structure. The ColumnFamilyHandle is automatically disposed with DB disposal.- Parameters:
columnFamilyDescriptor- column family to be created.- Returns:
ColumnFamilyHandleinstance.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
createColumnFamilyWithImport
public ColumnFamilyHandle createColumnFamilyWithImport(ColumnFamilyDescriptor columnFamilyDescriptor, ImportColumnFamilyOptions importColumnFamilyOptions, List<ExportImportFilesMetaData> metadatas) throws RocksDBException - Throws:
RocksDBException
-
dropColumnFamily
Drops the column family specified bycolumnFamilyHandle. This call only records a drop record in the manifest and prevents the column family from flushing and compacting.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
dropColumnFamilies
- Throws:
RocksDBException
-
destroyColumnFamilyHandle
Deletes native column family handle of givenColumnFamilyHandleJava object and removes reference fromownedColumnFamilyHandles.- Parameters:
columnFamilyHandle- column family handle object.
-
put
Set the database entry for "key" to "value".- Parameters:
key- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
put
public void put(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Set the database entry for "key" to "value".- Parameters:
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)- Throws:
RocksDBException- thrown if errors happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException Set the database entry for "key" to "value" in the specified column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- the specified key to be inserted.value- the value associated with the specified key.throws IllegalArgumentException if column family is not present
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Set the database entry for "key" to "value" in the specified column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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)- Throws:
RocksDBException- thrown if errors happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
put
Set the database entry for "key" to "value".- Parameters:
writeOpts-WriteOptionsinstance.key- the specified key to be inserted.value- the value associated with the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
put
public void put(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Set the database entry for "key" to "value".- Parameters:
writeOpts-WriteOptionsinstance.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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException Set the database entry for "key" to "value" for the specified column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpts-WriteOptionsinstance.key- the specified key to be inserted.value- the value associated with the specified key.throws IllegalArgumentException if column family is not present
- Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) throws RocksDBException Set the database entry for "key" to "value" for the specified column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpts-WriteOptionsinstance.key- the specified key to be inserted. Position and limit is used. Supports direct buffer only.value- the value associated with the specified key. Position and limit is used. Supports direct buffer only.throws IllegalArgumentException if column family is not present
- Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
put
Set the database entry for "key" to "value".- Parameters:
writeOpts-WriteOptionsinstance.key- the specified key to be inserted. Position and limit is used. Supports direct buffer only.value- the value associated with the specified key. Position and limit is used. Supports direct buffer only.throws IllegalArgumentException if column family is not present
- Throws:
RocksDBException- thrown if error happens in underlying native library.- See Also:
-
put
public void put(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Set the database entry for "key" to "value" for the specified column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpts-WriteOptionsinstance.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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
key- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
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)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) throws RocksDBException Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
writeOpt- WriteOptions to be used with delete operationkey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
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)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) throws RocksDBException Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpt- WriteOptions to be used with delete operationkey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key, int offset, int len) throws RocksDBException Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpt- 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)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
Get the value associated with the specified key within column family.- Parameters:
opt-ReadOptionsinstance.key- the key to retrieve the value. It is using position and limit. Supports direct buffer only.value- the out-value to receive the retrieved value. It is using position and limit. Limit is set according to value size. Supports direct buffer only.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, ByteBuffer key, ByteBuffer value) throws RocksDBException Get the value associated with the specified key within column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstanceopt-ReadOptionsinstance.key- the key to retrieve the value. It is using position and limit. Supports direct buffer only.value- the out-value to receive the retrieved value. It is using position and limit. Limit is set according to value size. Supports direct buffer only.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(byte[] key) throws RocksDBException Remove the database entry forkey. 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.
- Parameters:
key- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, byte[] key) throws RocksDBException Remove the database entry forkey. 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.
- Parameters:
columnFamilyHandle- The column family to delete the key fromkey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(WriteOptions writeOpt, byte[] key) throws RocksDBException Remove the database entry forkey. 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.- Parameters:
writeOpt- Write options for the deletekey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
singleDelete
@Experimental("Performance optimization for a very specific workload") public void singleDelete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] key) throws RocksDBException Remove the database entry forkey. 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.- Parameters:
columnFamilyHandle- The column family to delete the key fromwriteOpt- Write options for the deletekey- Key to delete within database- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
deleteRange
Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey". a non-OK status on error. It is not an error if no keys exist in the range ["beginKey", "endKey").Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
- Parameters:
beginKey- First key to delete within database (inclusive)endKey- Last key to delete within database (exclusive)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
deleteRange
public void deleteRange(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) throws RocksDBException Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey". a non-OK status on error. It is not an error if no keys exist in the range ["beginKey", "endKey").Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancebeginKey- First key to delete within database (inclusive)endKey- Last key to delete within database (exclusive)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
deleteRange
public void deleteRange(WriteOptions writeOpt, byte[] beginKey, byte[] endKey) throws RocksDBException Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey". a non-OK status on error. It is not an error if no keys exist in the range ["beginKey", "endKey").Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
- Parameters:
writeOpt- WriteOptions to be used with delete operationbeginKey- First key to delete within database (inclusive)endKey- Last key to delete within database (exclusive)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
deleteRange
public void deleteRange(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, byte[] beginKey, byte[] endKey) throws RocksDBException Removes the database entries in the range ["beginKey", "endKey"), i.e., including "beginKey" and excluding "endKey". a non-OK status on error. It is not an error if no keys exist in the range ["beginKey", "endKey").Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpt- WriteOptions to be used with delete operationbeginKey- First key to delete within database (included)endKey- Last key to delete within database (excluded)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
Add merge operand for key/value pair.- Parameters:
key- the specified key to be merged.value- the value to be merged with the current value for the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
public void merge(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Add merge operand for key/value pair.- Parameters:
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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException Add merge operand for key/value pair in a ColumnFamily.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- the specified key to be merged.value- the value to be merged with the current value for the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Add merge operand for key/value pair in a ColumnFamily.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
merge
Add merge operand for key/value pair.- Parameters:
writeOpts-WriteOptionsfor this write.key- the specified key to be merged.value- the value to be merged with the current value for the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
public void merge(WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Add merge operand for key/value pair.- Parameters:
writeOpts-WriteOptionsfor 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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
merge
- Throws:
RocksDBException
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) throws RocksDBException - Throws:
RocksDBException
-
delete
Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
writeOpt- WriteOptions to be used with delete operationkey- Key to delete within database. It is using position and limit. Supports direct buffer only.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
delete
public void delete(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpt, ByteBuffer key) throws RocksDBException Delete the database entry (if any) for "key". Returns OK on success, and a non-OK status on error. It is not an error if "key" did not exist in the database.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpt- WriteOptions to be used with delete operationkey- Key to delete within database. It is using position and limit. Supports direct buffer only.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException Add merge operand for key/value pair.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpts-WriteOptionsfor this write.key- the specified key to be merged.value- the value to be merged with the current value for the specified key.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
merge
public void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Add merge operand for key/value pair.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancewriteOpts-WriteOptionsfor 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)- Throws:
RocksDBException- thrown if error happens in underlying native library.IndexOutOfBoundsException- if an offset or length is out of bounds
-
write
Apply the specified updates to the database.- Parameters:
writeOpts- WriteOptions instanceupdates- WriteBatch instance- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
write
Apply the specified updates to the database.- Parameters:
writeOpts- WriteOptions instanceupdates- WriteBatchWithIndex instance- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
Get the value associated with the specified key within column family*- Parameters:
key- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Get the value associated with the specified key within column family*- Parameters:
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)- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(ColumnFamilyHandle columnFamilyHandle, byte[] key, byte[] value) throws RocksDBException, IllegalArgumentException Get the value associated with the specified key within column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.IllegalArgumentException
-
get
public int get(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException, IllegalArgumentException Get the value associated with the specified key within column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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)- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.IllegalArgumentException
-
get
Get the value associated with the specified key.- Parameters:
opt-ReadOptionsinstance.key- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(ReadOptions opt, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Get the value associated with the specified key.- Parameters:
opt-ReadOptionsinstance.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)- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, byte[] value) throws RocksDBException Get the value associated with the specified key within column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstanceopt-ReadOptionsinstance.key- the key to retrieve the value.value- the out-value to receive the retrieved value.- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public int get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, int offset, int len, byte[] value, int vOffset, int vLen) throws RocksDBException Get the value associated with the specified key within column family.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstanceopt-ReadOptionsinstance.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)- Returns:
- The size of the actual value that matches the specified
keyin byte. If the return value is greater than the length ofvalue, then it indicates that the size of the input buffervalueis insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found. - Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
key- the key retrieve the value.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
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)- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- the key retrieve the value.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public byte[] get(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len) throws RocksDBException The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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)- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
opt- Read options.key- the key retrieve the value.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
opt- Read options.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)- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public byte[] get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key) throws RocksDBException The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstanceopt- Read options.key- the key retrieve the value.- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
get
public byte[] get(ColumnFamilyHandle columnFamilyHandle, ReadOptions opt, byte[] key, int offset, int len) throws RocksDBException The simplified version of get which returns a new byte array storing the value associated with the specified input key if any. null will be returned if the specified key is not found.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstanceopt- Read options.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)- Returns:
- a byte array storing the value associated with the input key if any. null if it does not find the specified key.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetAsList
Takes a list of keys, and returns a list of values for the given list of keys. List will contain null for keys which could not be found.- Parameters:
keys- List of keys for which values need to be retrieved.- Returns:
- List of values for the given list of keys. List will contain null for keys which could not be found.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetAsList
public List<byte[]> multiGetAsList(List<ColumnFamilyHandle> columnFamilyHandleList, List<byte[]> keys) throws RocksDBException, IllegalArgumentException Returns a list of values for the given list of keys. List will contain null for keys which could not be found.Note: Every key needs to have a related column family name in
columnFamilyHandleList.- Parameters:
columnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.keys- List of keys for which values need to be retrieved.- Returns:
- List of values for the given list of keys. List will contain null for keys which could not be found.
- Throws:
RocksDBException- thrown if error happens in underlying native library.IllegalArgumentException- thrown if the size of passed keys is not equal to the amount of passed column family handles.
-
multiGetAsList
Returns a list of values for the given list of keys. List will contain null for keys which could not be found.- Parameters:
opt- Read options.keys- of keys for which values need to be retrieved.- Returns:
- List of values for the given list of keys. List will contain null for keys which could not be found.
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
multiGetAsList
public List<byte[]> multiGetAsList(ReadOptions opt, List<ColumnFamilyHandle> columnFamilyHandleList, List<byte[]> keys) throws RocksDBException Returns a list of values for the given list of keys. List will contain null for keys which could not be found.Note: Every key needs to have a related column family name in
columnFamilyHandleList.- Parameters:
opt- Read options.columnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.keys- of keys for which values need to be retrieved.- Returns:
- List of values for the given list of keys. List will contain null for keys which could not be found.
- Throws:
RocksDBException- thrown if error happens in underlying native library.IllegalArgumentException- thrown if the size of passed keys is not equal to the amount of passed column family handles.
-
multiGetByteBuffers
public List<ByteBufferGetStatus> multiGetByteBuffers(List<ByteBuffer> keys, List<ByteBuffer> values) throws RocksDBException Fetches a list of values for the given list of keys, all from the default column family.- Parameters:
keys- list of keys for which values need to be retrieved.values- list of buffers to return retrieved values in- Returns:
- list of number of bytes in DB for each requested key this can be more than the size of the corresponding buffer; then the buffer will be filled with the appropriate truncation of the database value.
- Throws:
RocksDBException- if error happens in underlying native library.IllegalArgumentException- thrown if the number of passed keys and passed values do not match.
-
multiGetByteBuffers
public List<ByteBufferGetStatus> multiGetByteBuffers(ReadOptions readOptions, List<ByteBuffer> keys, List<ByteBuffer> values) throws RocksDBException Fetches a list of values for the given list of keys, all from the default column family.- Parameters:
readOptions- Read optionskeys- list of keys for which values need to be retrieved.values- list of buffers to return retrieved values in- Returns:
- the list of values for the given list of keys
- Throws:
RocksDBException- if error happens in underlying native library.IllegalArgumentException- thrown if the number of passed keys and passed values do not match.
-
multiGetByteBuffers
public List<ByteBufferGetStatus> multiGetByteBuffers(List<ColumnFamilyHandle> columnFamilyHandleList, List<ByteBuffer> keys, List<ByteBuffer> values) throws RocksDBException Fetches a list of values for the given list of keys.Note: Every key needs to have a related column family name in
columnFamilyHandleList.- Parameters:
columnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.keys- list of keys for which values need to be retrieved.values- list of buffers to return retrieved values in- Returns:
- the list of values for the given list of keys
- Throws:
RocksDBException- if error happens in underlying native library.IllegalArgumentException- thrown if the number of passed keys, passed values and passed column family handles do not match.
-
multiGetByteBuffers
public List<ByteBufferGetStatus> multiGetByteBuffers(ReadOptions readOptions, List<ColumnFamilyHandle> columnFamilyHandleList, List<ByteBuffer> keys, List<ByteBuffer> values) throws RocksDBException Fetches a list of values for the given list of keys.Note: Every key needs to have a related column family name in
columnFamilyHandleList.- Parameters:
readOptions- Read optionscolumnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.keys- list of keys for which values need to be retrieved.values- list of buffers to return retrieved values in- Returns:
- the list of values for the given list of keys
- Throws:
RocksDBException- if error happens in underlying native library.IllegalArgumentException- thrown if the number of passed keys, passed values and passed column family handles do not match.
-
keyExists
public boolean keyExists(byte[] key) Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
key- byte array of a key to search for*- Returns:
- true if key exist in database, otherwise false.
-
keyExists
public boolean keyExists(byte[] key, int offset, int len) Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
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".length- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- byte array of a key to search for- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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".length- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
readOptions-ReadOptionsinstancekey- byte array of a key to search for- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
readOptions-ReadOptionsinstancekey- 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".length- Returns:
- true if key exist in database, otherwise false.
-
keyExists
public boolean keyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key) Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstancekey- byte array of a key to search for- Returns:
- true if key exist in database, otherwise false.
-
keyExists
public boolean keyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, int offset, int len) Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstancekey- 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".length- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
key- ByteBuffer with key. Must be allocated as direct.- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- ByteBuffer with key. Must be allocated as direct.- Returns:
- true if key exist in database, otherwise false.
-
keyExists
Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
readOptions-ReadOptionsinstancekey- ByteBuffer with key. Must be allocated as direct.- Returns:
- true if key exist in database, otherwise false.
-
keyExists
public boolean keyExists(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key) Check if a key exists in the database. This method is not as lightweight askeyMayExistbut it gives a 100% guarantee of a correct result, whether the key exists or not. Internally it checks if the key may exist and then double checks with read operation that confirms the key exists. This deals with the case wherekeyMayExistmay return a false positive. The code crosses the Java/JNI boundary only once.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstancekey- ByteBuffer with key. Must be allocated as direct.- Returns:
- true if key exist in database, otherwise false.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(byte[]). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
key- byte array of a key to search forvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(byte[], int, int). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
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".lengthvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ColumnFamilyHandle,byte[]). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- byte array of a key to search forvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ColumnFamilyHandle, byte[], int, int). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancekey- 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".lengthvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a true negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ReadOptions, byte[]). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
readOptions-ReadOptionsinstancekey- byte array of a key to search forvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public boolean keyMayExist(ReadOptions readOptions, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a true negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ReadOptions, byte[], int, int). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
readOptions-ReadOptionsinstancekey- 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".lengthvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a true negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ColumnFamilyHandle, ReadOptions, byte[]). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstancekey- byte array of a key to search forvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, byte[] key, int offset, int len, Holder<byte[]> valueHolder) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.If the caller wants to obtain value when the key is found in memory, then
valueHoldermust be set.This check is potentially lighter-weight than invoking
get(ColumnFamilyHandle, ReadOptions, byte[], int, int). One way to make this lighter weight is to avoid doing any IOs.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstancekey- 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".lengthvalueHolder- non-null to retrieve the value if it is found, or null if the value is not needed. If non-null, upon return of the function, thevaluewill be set if it could be retrieved.- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.- Parameters:
key- bytebuffer containing the value of the key- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.- Parameters:
columnFamilyHandle- theColumnFamilyHandleto look for the key inkey- bytebuffer containing the value of the key- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.- Parameters:
readOptions- theReadOptionsto use when reading the key/valuekey- bytebuffer containing the value of the key- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is thatKeyMayExist.KeyMayExistEnum.kNotExistis an assurance that the key does not exist.- Parameters:
key- bytebuffer containing the value of the keyvalue- bytebuffer which will receive a value if the key exists and a value is known- Returns:
- a
KeyMayExistobject reporting if key may exist and if a value is provided
-
keyMayExist
public KeyMayExist keyMayExist(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is thatKeyMayExist.KeyMayExistEnum.kNotExistis an assurance that the key does not exist.- Parameters:
columnFamilyHandle- theColumnFamilyHandleto look for the key inkey- bytebuffer containing the value of the keyvalue- bytebuffer which will receive a value if the key exists and a value is known- Returns:
- a
KeyMayExistobject reporting if key may exist and if a value is provided
-
keyMayExist
If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is thatKeyMayExist.KeyMayExistEnum.kNotExistis an assurance that the key does not exist.- Parameters:
readOptions- theReadOptionsto use when reading the key/valuekey- bytebuffer containing the value of the keyvalue- bytebuffer which will receive a value if the key exists and a value is known- Returns:
- a
KeyMayExistobject reporting if key may exist and if a value is provided
-
keyMayExist
public boolean keyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key) If the key definitely does not exist in the database, then this method returns false, otherwise it returns true if the key might exist. That is to say that this method is probabilistic and may return false positives, but never a false negative.- Parameters:
columnFamilyHandle- theColumnFamilyHandleto look for the key inreadOptions- theReadOptionsto use when reading the key/valuekey- bytebuffer containing the value of the key- Returns:
- false if the key definitely does not exist in the database, otherwise true.
-
keyMayExist
public KeyMayExist keyMayExist(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions, ByteBuffer key, ByteBuffer value) If the key definitely does not exist in the database, then this method returnsKeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returnsKeyMayExist.KeyMayExistEnum.kExistsWithValueotherwise it returnsKeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is thatKeyMayExist.KeyMayExistEnum.kNotExistis an assurance that the key does not exist.- Parameters:
columnFamilyHandle- theColumnFamilyHandleto look for the key inreadOptions- theReadOptionsto use when reading the key/valuekey- bytebuffer containing the value of the keyvalue- bytebuffer which will receive a value if the key exists and a value is known- Returns:
- a
KeyMayExistobject reporting if key may exist and if a value is provided
-
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.
- Returns:
- instance of iterator object.
-
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.
- Parameters:
readOptions-ReadOptionsinstance.- Returns:
- instance of iterator object.
-
newIterator
Return a heap-allocated iterator over the contents of a ColumnFamily. 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.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance- Returns:
- instance of iterator object.
-
newIterator
Return a heap-allocated iterator over the contents of a ColumnFamily. 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.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancereadOptions-ReadOptionsinstance.- Returns:
- instance of iterator object.
-
newIterators
public List<RocksIterator> newIterators(List<ColumnFamilyHandle> columnFamilyHandleList) throws RocksDBException Returns iterators from a consistent database state across multiple column families. Iterators are heap allocated and need to be deleted before the db is deleted- Parameters:
columnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.- Returns:
ListcontainingRocksIteratorinstances- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
newIterators
public List<RocksIterator> newIterators(List<ColumnFamilyHandle> columnFamilyHandleList, ReadOptions readOptions) throws RocksDBException Returns iterators from a consistent database state across multiple column families. Iterators are heap allocated and need to be deleted before the db is deleted- Parameters:
columnFamilyHandleList-ListcontainingColumnFamilyHandleinstances.readOptions-ReadOptionsinstance.- Returns:
ListcontainingRocksIteratorinstances- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
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.
- Returns:
- Snapshot
Snapshotinstance
-
releaseSnapshot
Release a previously acquired snapshot.The caller must not use "snapshot" after this call.
- Parameters:
snapshot-Snapshotinstance
-
getProperty
public String getProperty(ColumnFamilyHandle columnFamilyHandle, String property) throws RocksDBException DB implements can export properties about their state via this method on a per column family level.If
propertyis a valid property understood by this DB implementation, fillsvaluewith its current value and returns true. Otherwise returns false.Valid property names include:
- "rocksdb.num-files-at-level<N>" - return the number of files at level <N>, where <N> is an ASCII representation of a level number (e.g. "0").
- "rocksdb.stats" - returns a multi-line string that describes statistics about the internal operation of the DB.
- "rocksdb.sstables" - returns a multi-line string that describes all of the sstables that make up the db contents.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.property- to be fetched. See above for examples- Returns:
- property value
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getProperty
DB implementations can export properties about their state via this method. 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:
- "rocksdb.num-files-at-level<N>" - return the number of files at level <N>, where <N> is an ASCII representation of a level number (e.g. "0").
- "rocksdb.stats" - returns a multi-line string that describes statistics about the internal operation of the DB.
- "rocksdb.sstables" - returns a multi-line string that describes all of the sstables that make up the db contents.
- Parameters:
property- to be fetched. See above for examples- Returns:
- property value
- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
getMapProperty
Gets a property map.- Parameters:
property- to be fetched.- Returns:
- the property map
- Throws:
RocksDBException- if an error happens in the underlying native code.
-
getMapProperty
public Map<String,String> getMapProperty(ColumnFamilyHandle columnFamilyHandle, String property) throws RocksDBException Gets a property map.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.property- to be fetched.- Returns:
- the property map
- Throws:
RocksDBException- if an error happens in the underlying native code.
-
getLongProperty
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_ton 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
BigIntegerto reflect the correct value. The correct behavior is guaranteed if2^64is added to negative values.Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type
Long.- Parameters:
property- to be fetched.- Returns:
- numerical property value.
- Throws:
RocksDBException- if an error happens in the underlying native code.
-
getLongProperty
public long getLongProperty(ColumnFamilyHandle columnFamilyHandle, 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_ton 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
BigIntegerto reflect the correct value. The correct behavior is guaranteed if2^64is added to negative values.Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type
Long.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column familyproperty- to be fetched.- Returns:
- numerical property value
- Throws:
RocksDBException- if an error happens in the underlying native code.
-
resetStats
Reset internal stats for DB and all column families.Note this doesn't reset
Options.statistics()as it is not owned by DB.- Throws:
RocksDBException- if an error occurs whilst reseting the stats
-
getAggregatedLongProperty
Return sum of the getLongProperty of all the column families
Note: As the returned property is of type
uint64_ton 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
BigIntegerto reflect the correct value. The correct behavior is guaranteed if2^64is added to negative values.Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type
Long.- Parameters:
property- to be fetched.- Returns:
- numerical property value
- Throws:
RocksDBException- if an error happens in the underlying native code.
-
getApproximateSizes
public long[] getApproximateSizes(ColumnFamilyHandle columnFamilyHandle, List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags) Get the approximate file system space used by keys in each range.Note that the returned sizes measure file system space usage, so if the user data compresses by a factor of ten, the returned sizes will be one-tenth the size of the corresponding user data size.
If
sizeApproximationFlagsdefines 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.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column familyranges- the ranges over which to approximate sizessizeApproximationFlags- flags to determine what to include in the approximation.- Returns:
- the sizes
-
getApproximateSizes
public long[] getApproximateSizes(List<Range> ranges, SizeApproximationFlag... sizeApproximationFlags) Get the approximate file system space used by keys in each range for the default column family.Note that the returned sizes measure file system space usage, so if the user data compresses by a factor of ten, the returned sizes will be one-tenth the size of the corresponding user data size.
If
sizeApproximationFlagsdefines 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.- Parameters:
ranges- the ranges over which to approximate sizessizeApproximationFlags- flags to determine what to include in the approximation.- Returns:
- the sizes.
-
getApproximateMemTableStats
public RocksDB.CountAndSize getApproximateMemTableStats(ColumnFamilyHandle columnFamilyHandle, Range range) This method is similar togetApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column familyrange- the ranges over which to get the memtable stats- Returns:
- the count and size for the range
-
getApproximateMemTableStats
This method is similar togetApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.- Parameters:
range- the ranges over which to get the memtable stats- Returns:
- the count and size for the range
-
compactRange
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
- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
compactRange
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
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
compactRange
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
- Parameters:
begin- start of key range (included in range)end- end of key range (excluded from range)- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
compactRange
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
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.begin- start of key range (included in range)end- end of key range (excluded from range)- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
compactRange
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.
- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance.begin- start of key range (included in range)end- end of key range (excluded from range)compactRangeOptions- options for the compaction- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
clipColumnFamily
public void clipColumnFamily(ColumnFamilyHandle columnFamilyHandle, byte[] beginKey, byte[] endKey) throws RocksDBException ClipColumnFamily() will clip the entries in the CF according to the range [begin_key, end_key). Returns OK on success, and a non-OK status on error. Any entries outside this range will be completely deleted (including tombstones).- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstancebeginKey- First key to clip within database (inclusive)endKey- Last key to clip within database (exclusive)- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
setOptions
public void setOptions(ColumnFamilyHandle columnFamilyHandle, MutableColumnFamilyOptions mutableColumnFamilyOptions) throws RocksDBException Change the options for the column family handle.- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.mutableColumnFamilyOptions- the options.- Throws:
RocksDBException- if an error occurs whilst setting the options
-
setPerfLevel
Set performance level for rocksdb performance measurement.- Parameters:
level-- Throws:
IllegalArgumentException- for UNINITIALIZED and OUT_OF_BOUNDS values as they can't be used for settings.
-
getPerfLevel
Return current performance level measurement settings.- Returns:
-
getPerfContext
Return perf context bound to this thread.- Returns:
-
getOptions
public MutableColumnFamilyOptions.MutableColumnFamilyOptionsBuilder getOptions(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException Get the options for the column family handle- Parameters:
columnFamilyHandle-ColumnFamilyHandleinstance, or null for the default column family.- Returns:
- the options parsed from the options string return by RocksDB
- Throws:
RocksDBException- if an error occurs while getting the options string, or parsing the resulting options string into options
-
getOptions
public MutableColumnFamilyOptions.MutableColumnFamilyOptionsBuilder getOptions() throws RocksDBExceptionDefault column family options- Returns:
- the options parsed from the options string return by RocksDB
- Throws:
RocksDBException- if an error occurs while getting the options string, or parsing the resulting options string into options
-
getDBOptions
Get the database options- Returns:
- the DB options parsed from the options string return by RocksDB
- Throws:
RocksDBException- if an error occurs while getting the options string, or parsing the resulting options string into options
-
setOptions
public void setOptions(MutableColumnFamilyOptions mutableColumnFamilyOptions) throws RocksDBException Change the options for the default column family handle.- Parameters:
mutableColumnFamilyOptions- the options.- Throws:
RocksDBException- if an error occurs whilst setting the options
-
setDBOptions
Set the options for the column family handle.- Parameters:
mutableDBoptions- the options.- Throws:
RocksDBException- if an error occurs whilst setting the options
-
compactFiles
public List<String> compactFiles(CompactionOptions compactionOptions, List<String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) throws RocksDBException Takes a list of files specified by file names and compacts them to the specified level.Note that the behavior is different from
compactRange(ColumnFamilyHandle, byte[], byte[])in that CompactFiles() performs the compaction job using the CURRENT thread.- Parameters:
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.- Returns:
- the list of compacted files
- Throws:
RocksDBException- if an error occurs during compaction
-
compactFiles
public List<String> compactFiles(CompactionOptions compactionOptions, ColumnFamilyHandle columnFamilyHandle, List<String> inputFileNames, int outputLevel, int outputPathId, CompactionJobInfo compactionJobInfo) throws RocksDBException Takes a list of files specified by file names and compacts them to the specified level.Note that the behavior is different from
compactRange(ColumnFamilyHandle, byte[], byte[])in that CompactFiles() performs the compaction job using the CURRENT thread.- Parameters:
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.- Returns:
- the list of compacted files
- Throws:
RocksDBException- if an error occurs during compaction
-
cancelAllBackgroundWork
public void cancelAllBackgroundWork(boolean wait) This function will cancel all currently running background processes.- Parameters:
wait- if true, wait for all background work to be cancelled before returning.
-
pauseBackgroundWork
This function will wait until all currently running background processes finish. After it returns, no background process will be run untilcontinueBackgroundWork()is called- Throws:
RocksDBException- if an error occurs when pausing background work
-
continueBackgroundWork
Resumes background work which was suspended by previously callingpauseBackgroundWork()- Throws:
RocksDBException- if an error occurs when resuming background work
-
enableAutoCompaction
public void enableAutoCompaction(List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException Enable automatic compactions for the given column families if they were previously disabled.The function will first set the
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.- Parameters:
columnFamilyHandles- the column family handles- Throws:
RocksDBException- if an error occurs whilst enabling auto-compaction
-
numberLevels
public int numberLevels()Number of levels used for this DB.- Returns:
- the number of levels
-
numberLevels
Number of levels used for a column family in this DB.- Parameters:
columnFamilyHandle- the column family handle, or null for the default column family- Returns:
- the number of levels
-
maxMemCompactionLevel
public int maxMemCompactionLevel()Maximum level to which a new compacted memtable is pushed if it does not create overlap.- Returns:
- the maximum level
-
maxMemCompactionLevel
Maximum level to which a new compacted memtable is pushed if it does not create overlap.- Parameters:
columnFamilyHandle- the column family handle- Returns:
- the maximum level
-
level0StopWriteTrigger
public int level0StopWriteTrigger()Number of files in level-0 that would stop writes.- Returns:
- the number of files
-
level0StopWriteTrigger
Number of files in level-0 that would stop writes.- Parameters:
columnFamilyHandle- the column family handle- Returns:
- the number of files
-
getName
Get DB name -- the exact same name that was provided as an argument to as path toopen(Options, String).- Returns:
- the DB name
-
getEnv
Get the Env object from the DB- Returns:
- the env
-
flush
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.
- Parameters:
flushOptions-FlushOptionsinstance.- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
flush
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.
- Parameters:
flushOptions-FlushOptionsinstance.columnFamilyHandle-ColumnFamilyHandleinstance.- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
flush
public void flush(FlushOptions flushOptions, List<ColumnFamilyHandle> columnFamilyHandles) throws RocksDBException Flushes multiple column families.If atomic flush is not enabled, this is equivalent to calling
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.
- Parameters:
flushOptions-FlushOptionsinstance.columnFamilyHandles- column family handles.- Throws:
RocksDBException- thrown if an error occurs within the native part of the library.
-
flushWal
Flush the WAL memory buffer to the file. Ifsyncis true, it callssyncWal()afterwards.- Parameters:
sync- true to also fsync to disk.- Throws:
RocksDBException- if an error occurs whilst flushing
-
syncWal
Sync the WAL.Note that
write(WriteOptions, WriteBatch)followed by#syncWal()is not exactly the same aswrite(WriteOptions, WriteBatch)withWriteOptions.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.- Throws:
RocksDBException- if an error occurs whilst syncing
-
getLatestSequenceNumber
public long getLatestSequenceNumber()The sequence number of the most recent transaction.
- Returns:
- sequence number of the most recent transaction.
-
disableFileDeletions
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.
- Throws:
RocksDBException- thrown if operation was not performed successfully.
-
enableFileDeletions
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()
- Throws:
RocksDBException- thrown if operation was not performed successfully.
-
getLiveFiles
Retrieve the list of all files in the database after flushing the memtable.- Returns:
- the live files
- Throws:
RocksDBException- if an error occurs whilst retrieving the list of live files
-
getLiveFiles
Retrieve the list of all files in the database.In case you have multiple column families, even if
flushMemtableis true, you still need to callgetSortedWalFiles()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 bygetSortedWalFiles()can generate a lossless backup.- Parameters:
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.- Returns:
- the live files
- Throws:
RocksDBException- if an error occurs whilst retrieving the list of live files
-
getSortedWalFiles
Retrieve the sorted list of all wal files with earliest file first.- Returns:
- the log files
- Throws:
RocksDBException- if an error occurs whilst retrieving the list of sorted WAL files
-
getUpdatesSince
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.
- Parameters:
sequenceNumber- sequence number offset- Returns:
TransactionLogIteratorinstance.- Throws:
RocksDBException- if iterator cannot be retrieved from native-side.
-
deleteFile
Delete the file name from the db directory and update the internal state to reflect that. Supports deletion of sst and log files only. 'name' must be path relative to the db directory. eg. 000001.sst, /archive/000003.log- Parameters:
name- the file name- Throws:
RocksDBException- if an error occurs whilst deleting the file
-
getLiveFilesMetaData
Gets a list of all table files metadata.- Returns:
- table files metadata.
-
getColumnFamilyMetaData
Obtains the meta data of the specified column family of the DB.- Parameters:
columnFamilyHandle- the column family- Returns:
- the column family metadata
-
getColumnFamilyMetaData
Obtains the meta data of the default column family of the DB.- Returns:
- the column family metadata
-
ingestExternalFile
public void ingestExternalFile(List<String> filePathList, IngestExternalFileOptions ingestExternalFileOptions) throws RocksDBException 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). A file that have a key range that overlap with the memtable key range will require us to Flush the memtable first before ingesting the file.(1) External SST files can be created using
SstFileWriter(2) We will try to ingest the files to the lowest possible level even if the file compression doesn't match the level compression- Parameters:
filePathList- The list of files to ingestingestExternalFileOptions- the options for the ingestion- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
ingestExternalFile
public void ingestExternalFile(ColumnFamilyHandle columnFamilyHandle, List<String> filePathList, IngestExternalFileOptions ingestExternalFileOptions) throws RocksDBException 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). A file that have a key range that overlap with the memtable key range will require us to Flush the memtable first before ingesting the file.(1) External SST files can be created using
SstFileWriter(2) We will try to ingest the files to the lowest possible level even if the file compression doesn't match the level compression- Parameters:
columnFamilyHandle- The column family for the ingested filesfilePathList- The list of files to ingestingestExternalFileOptions- the options for the ingestion- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
verifyChecksum
Verify checksum- Throws:
RocksDBException- if the checksum is not valid
-
getDefaultColumnFamily
Gets the handle for the default column family- Returns:
- The handle of the default column family
-
makeDefaultColumnFamilyHandle
Create a handle for the default CF on open- Returns:
- the default family handle
-
getPropertiesOfAllTables
public Map<String,TableProperties> getPropertiesOfAllTables(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException Get the properties of all tables.- Parameters:
columnFamilyHandle- the column family handle, or null for the default column family.- Returns:
- the properties
- Throws:
RocksDBException- if an error occurs whilst getting the properties
-
getPropertiesOfAllTables
Get the properties of all tables in the default column family.- Returns:
- the properties
- Throws:
RocksDBException- if an error occurs whilst getting the properties
-
getPropertiesOfTablesInRange
public Map<String,TableProperties> getPropertiesOfTablesInRange(ColumnFamilyHandle columnFamilyHandle, List<Range> ranges) throws RocksDBException Get the properties of tables in range.- Parameters:
columnFamilyHandle- the column family handle, or null for the default column family.ranges- the ranges over which to get the table properties- Returns:
- the properties
- Throws:
RocksDBException- if an error occurs whilst getting the properties
-
getPropertiesOfTablesInRange
public Map<String,TableProperties> getPropertiesOfTablesInRange(List<Range> ranges) throws RocksDBException Get the properties of tables in range for the default column family.- Parameters:
ranges- the ranges over which to get the table properties- Returns:
- the properties
- Throws:
RocksDBException- if an error occurs whilst getting the properties
-
suggestCompactRange
Suggest the range to compact.- Parameters:
columnFamilyHandle- the column family handle, or null for the default column family.- Returns:
- the suggested range.
- Throws:
RocksDBException- if an error occurs whilst suggesting the range
-
suggestCompactRange
Suggest the range to compact for the default column family.- Returns:
- the suggested range.
- Throws:
RocksDBException- if an error occurs whilst suggesting the range
-
promoteL0
public void promoteL0(ColumnFamilyHandle columnFamilyHandle, int targetLevel) throws RocksDBException Promote L0.- Parameters:
columnFamilyHandle- the column family handle, or null for the default column family.targetLevel- the target level for L0- Throws:
RocksDBException- if an error occurs whilst promoting L0
-
promoteL0
Promote L0 for the default column family.- Parameters:
targetLevel- the target level for L0- Throws:
RocksDBException- if an error occurs whilst promoting L0
-
startTrace
public void startTrace(TraceOptions traceOptions, AbstractTraceWriter traceWriter) throws RocksDBException Trace DB operations.Use
endTrace()to stop tracing.- Parameters:
traceOptions- the optionstraceWriter- the trace writer- Throws:
RocksDBException- if an error occurs whilst starting the trace
-
endTrace
Stop tracing DB operations.- Throws:
RocksDBException- if an error occurs whilst ending the trace
-
tryCatchUpWithPrimary
Make the secondary instance catch up with the primary by tailing and replaying the MANIFEST and WAL of the primary. Column families created by the primary after the secondary instance starts will be ignored unless the secondary instance closes and restarts with the newly created column families. Column families that exist before secondary instance starts and dropped by the primary afterwards will be marked as dropped. However, as long as the secondary instance does not delete the corresponding column family handles, the data of the column family is still accessible to the secondary.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
deleteFilesInRanges
public void deleteFilesInRanges(ColumnFamilyHandle columnFamily, List<byte[]> ranges, boolean includeEnd) throws RocksDBException Delete files in multiple ranges at once. Delete files in a lot of ranges one at a time can be slow, use this API for better performance in that case.- Parameters:
columnFamily- - The column family for operation (null for default)ranges- - pairs of ranges (from1, to1, from2, to2, ...)includeEnd- - Whether ranges should include end- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
destroyDB
Static method to destroy the contents of the specified database. Be very careful using this method.- Parameters:
path- the path to the Rocksdb database.options-Optionsinstance.- Throws:
RocksDBException- thrown if error happens in underlying native library.
-
storeOptionsInstance
-
storeDefaultColumnFamilyHandle
-
disposeInternal
protected void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-