Package org.rocksdb

Class RocksDB

All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
OptimisticTransactionDB, TransactionDB, TtlDB

public class RocksDB extends RocksObject
A RocksDB is a persistent ordered map from keys to values. It is safe for concurrent access from multiple threads without any external synchronization. All methods of this class could potentially throw RocksDBException, which indicates sth wrong at the RocksDB library side and the call failed.
  • Field Details

    • DEFAULT_COLUMN_FAMILY

      public static final byte[] DEFAULT_COLUMN_FAMILY
    • NOT_FOUND

      public static final int NOT_FOUND
      See Also:
    • options_

      protected DBOptionsInterface<?> 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

      public static void loadLibrary(List<String> paths)
      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

      public static RocksDB.Version rocksdbVersion()
    • isClosed

      public boolean isClosed()
    • open

      public static RocksDB open(String path) throws RocksDBException
      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 RocksDB instance on success, null if the specified RocksDB can 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 descriptors
      columnFamilyHandles - will be filled with ColumnFamilyHandle instances on open.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can not be opened.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
      See Also:
    • open

      public static RocksDB open(Options options, String path) 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.

      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 - Options instance.
      path - the path to the rocksdb.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can 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 - DBOptions instance.
      path - the path to the rocksdb.
      columnFamilyDescriptors - list of column family descriptors
      columnFamilyHandles - will be filled with ColumnFamilyHandle instances on open.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can not be opened.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
      See Also:
    • openReadOnly

      public static RocksDB openReadOnly(String path) 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.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can not be opened.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • openReadOnly

      public static RocksDB openReadOnly(Options options, String path) 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 - Options instance.
      path - the path to the RocksDB.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can 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 - Options instance.
      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 RocksDB instance on success, null if the specified RocksDB can 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 descriptors
      columnFamilyHandles - will be filled with ColumnFamilyHandle instances on open.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can 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 - DBOptions instance.
      path - the path to the RocksDB.
      columnFamilyDescriptors - list of column family descriptors
      columnFamilyHandles - will be filled with ColumnFamilyHandle instances on open.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can 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 - DBOptions instance.
      path - the path to the RocksDB.
      columnFamilyDescriptors - list of column family descriptors
      columnFamilyHandles - 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 RocksDB instance on success, null if the specified RocksDB can 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 RocksDB instance on success, null if the specified RocksDB can 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 descriptors
      columnFamilyHandles - will be filled with ColumnFamilyHandle instances on open.
      Returns:
      a RocksDB instance on success, null if the specified RocksDB can not be opened.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • closeE

      public void closeE() throws RocksDBException
      This is similar to close() except that it throws an exception if any error occurs.

      This will not fsync the WAL files. If syncing is required, the caller must first call syncWal() or write(WriteOptions, WriteBatch) using an empty write batch with WriteOptions.setSync(boolean) set to true.

      See also close().

      Throws:
      RocksDBException - if an error occurs whilst closing.
    • close

      public void close()
      This is similar to closeE() except that it silently ignores any errors.

      This will not fsync the WAL files. If syncing is required, the caller must first call syncWal() or write(WriteOptions, WriteBatch) using an empty write batch with WriteOptions.setSync(boolean) set to true.

      See also close().

      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class AbstractImmutableNativeReference
    • listColumnFamilies

      public static List<byte[]> listColumnFamilies(Options options, String path) throws RocksDBException
      Static method to determine all available column families for a rocksdb database identified by path
      Parameters:
      options - Options for opening the database
      path - 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:
      ColumnFamilyHandle instance.
      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:
      ColumnFamilyHandle instance.
      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

      public void dropColumnFamily(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
      Drops the column family specified by columnFamilyHandle. This call only records a drop record in the manifest and prevents the column family from flushing and compacting.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • dropColumnFamilies

      public void dropColumnFamilies(List<ColumnFamilyHandle> columnFamilies) throws RocksDBException
      Throws:
      RocksDBException
    • destroyColumnFamilyHandle

      public void destroyColumnFamilyHandle(ColumnFamilyHandle columnFamilyHandle)
      Deletes native column family handle of given ColumnFamilyHandle Java object and removes reference from ownedColumnFamilyHandles.
      Parameters:
      columnFamilyHandle - column family handle object.
    • put

      public void put(byte[] key, byte[] value) throws RocksDBException
      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 inserted
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 key
      vOffset - the offset of the "value" array to be used, must be non-negative and no longer than "key".length
      vLen - 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 - ColumnFamilyHandle instance
      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.
    • 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 - ColumnFamilyHandle instance
      key - The specified key to be inserted
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 key
      vOffset - the offset of the "value" array to be used, must be non-negative and no longer than "key".length
      vLen - 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(WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
      Set the database entry for "key" to "value".
      Parameters:
      writeOpts - WriteOptions instance.
      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 - WriteOptions instance.
      key - The specified key to be inserted
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 key
      vOffset - the offset of the "value" array to be used, must be non-negative and no longer than "key".length
      vLen - 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 - ColumnFamilyHandle instance
      writeOpts - WriteOptions instance.
      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 - ColumnFamilyHandle instance
      writeOpts - WriteOptions instance.
      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(WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) throws RocksDBException
      Set the database entry for "key" to "value".
      Parameters:
      writeOpts - WriteOptions instance.
      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 - ColumnFamilyHandle instance
      writeOpts - WriteOptions instance.
      key - The specified key to be inserted
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 key
      vOffset - the offset of the "value" array to be used, must be non-negative and no longer than "key".length
      vLen - 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

      public void delete(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:
      key - Key to delete within database
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • delete

      public void delete(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:
      key - Key to delete within database
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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, 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 - ColumnFamilyHandle instance
      key - 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 - ColumnFamilyHandle instance
      key - Key to delete within database
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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

      public void delete(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:
      writeOpt - WriteOptions to be used with delete operation
      key - Key to delete within database
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • delete

      public void delete(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:
      writeOpt - WriteOptions to be used with delete operation
      key - Key to delete within database
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 - ColumnFamilyHandle instance
      writeOpt - WriteOptions to be used with delete operation
      key - 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 - ColumnFamilyHandle instance
      writeOpt - WriteOptions to be used with delete operation
      key - Key to delete within database
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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

      public int get(ReadOptions opt, ByteBuffer key, ByteBuffer value) throws RocksDBException
      Get the value associated with the specified key within column family.
      Parameters:
      opt - ReadOptions instance.
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ColumnFamilyHandle instance
      opt - ReadOptions instance.
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 for key. Requires that the key exists and was not overwritten. It is not an error if the key did not exist in the database.

      If a key is overwritten (by calling put(byte[], byte[]) multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.

      This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.

      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 for key. Requires that the key exists and was not overwritten. It is not an error if the key did not exist in the database.

      If a key is overwritten (by calling put(byte[], byte[]) multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.

      This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.

      Parameters:
      columnFamilyHandle - The column family to delete the key from
      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(WriteOptions writeOpt, byte[] key) throws RocksDBException
      Remove the database entry for key. Requires that the key exists and was not overwritten. It is not an error if the key did not exist in the database.

      If a key is overwritten (by calling put(byte[], byte[]) multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.

      This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.

      Note: consider setting WriteOptions.setSync(boolean) true.

      Parameters:
      writeOpt - Write options for the delete
      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, WriteOptions writeOpt, byte[] key) throws RocksDBException
      Remove the database entry for key. Requires that the key exists and was not overwritten. It is not an error if the key did not exist in the database.

      If a key is overwritten (by calling put(byte[], byte[]) multiple times), then the result of calling SingleDelete() on this key is undefined. SingleDelete() only behaves correctly if there has been only one Put() for this key since the previous call to SingleDelete() for this key.

      This feature is currently an experimental performance optimization for a very specific workload. It is up to the caller to ensure that SingleDelete is only used for a key that is not deleted using Delete() or written using Merge(). Mixing SingleDelete operations with Deletes and Merges can result in undefined behavior.

      Note: consider setting WriteOptions.setSync(boolean) true.

      Parameters:
      columnFamilyHandle - The column family to delete the key from
      writeOpt - Write options for the delete
      key - Key to delete within database
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • deleteRange

      public void deleteRange(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:
      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 - ColumnFamilyHandle instance
      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(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 operation
      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, 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 - ColumnFamilyHandle instance
      writeOpt - WriteOptions to be used with delete operation
      beginKey - 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

      public void merge(byte[] key, byte[] value) throws RocksDBException
      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".length
      len - 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".length
      vLen - 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 - ColumnFamilyHandle instance
      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, 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 - ColumnFamilyHandle instance
      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".length
      len - 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".length
      vLen - 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

      public void merge(WriteOptions writeOpts, byte[] key, byte[] value) throws RocksDBException
      Add merge operand for key/value pair.
      Parameters:
      writeOpts - WriteOptions for this write.
      key - the specified key to be merged.
      value - the value to be merged with the current value for the specified key.
      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 - WriteOptions for this write.
      key - the specified key to be merged.
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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".length
      vLen - 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

      public void merge(WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) throws RocksDBException
      Throws:
      RocksDBException
    • merge

      public void merge(ColumnFamilyHandle columnFamilyHandle, WriteOptions writeOpts, ByteBuffer key, ByteBuffer value) throws RocksDBException
      Throws:
      RocksDBException
    • delete

      public void delete(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:
      writeOpt - WriteOptions to be used with delete operation
      key - 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 - ColumnFamilyHandle instance
      writeOpt - WriteOptions to be used with delete operation
      key - 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 - ColumnFamilyHandle instance
      writeOpts - WriteOptions for this write.
      key - the specified key to be merged.
      value - the value to be merged with the current value for the specified key.
      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 - ColumnFamilyHandle instance
      writeOpts - WriteOptions for this write.
      key - the specified key to be merged.
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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".length
      vLen - 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

      public void write(WriteOptions writeOpts, WriteBatch updates) throws RocksDBException
      Apply the specified updates to the database.
      Parameters:
      writeOpts - WriteOptions instance
      updates - WriteBatch instance
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • write

      public void write(WriteOptions writeOpts, WriteBatchWithIndex updates) throws RocksDBException
      Apply the specified updates to the database.
      Parameters:
      writeOpts - WriteOptions instance
      updates - WriteBatchWithIndex instance
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • get

      public int get(byte[] key, byte[] value) throws RocksDBException
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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".length
      len - 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".length
      vLen - 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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ColumnFamilyHandle instance
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ColumnFamilyHandle instance
      key - the key to retrieve the value.
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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".length
      vLen - 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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
      IllegalArgumentException
    • get

      public int get(ReadOptions opt, byte[] key, byte[] value) throws RocksDBException
      Get the value associated with the specified key.
      Parameters:
      opt - ReadOptions instance.
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ReadOptions instance.
      key - the key to retrieve the value.
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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".length
      vLen - 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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ColumnFamilyHandle instance
      opt - ReadOptions instance.
      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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      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 - ColumnFamilyHandle instance
      opt - ReadOptions instance.
      key - the key to retrieve the value.
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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".length
      vLen - 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 key in byte. If the return value is greater than the length of value, then it indicates that the size of the input buffer value is insufficient and partial result will be returned. RocksDB.NOT_FOUND will be returned if the value not found.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • get

      public byte[] get(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:
      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(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:
      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".length
      len - 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, 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 - ColumnFamilyHandle instance
      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, 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 - ColumnFamilyHandle instance
      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".length
      len - 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(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:
      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

      public byte[] get(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:
      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".length
      len - 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 - ColumnFamilyHandle instance
      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

      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 - ColumnFamilyHandle instance
      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".length
      len - 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

      public List<byte[]> multiGetAsList(List<byte[]> keys) throws RocksDBException
      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 - List containing ColumnFamilyHandle instances.
      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

      public List<byte[]> multiGetAsList(ReadOptions opt, 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.
      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 - List containing ColumnFamilyHandle instances.
      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 options
      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 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 - List containing ColumnFamilyHandle instances.
      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 options
      columnFamilyHandleList - List containing ColumnFamilyHandle instances.
      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 as keyMayExist but 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 where keyMayExist may 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 as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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, byte[] key)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      key - byte array of a key to search for
      Returns:
      true if key exist in database, otherwise false.
    • keyExists

      public boolean keyExists(ColumnFamilyHandle columnFamilyHandle, byte[] key, int offset, int len)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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(ReadOptions readOptions, byte[] key)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      readOptions - ReadOptions instance
      key - byte array of a key to search for
      Returns:
      true if key exist in database, otherwise false.
    • keyExists

      public boolean keyExists(ReadOptions readOptions, byte[] key, int offset, int len)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      readOptions - ReadOptions instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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 as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      readOptions - ReadOptions instance
      key - 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 as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      readOptions - ReadOptions instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - 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(ByteBuffer key)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may 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

      public boolean keyExists(ColumnFamilyHandle columnFamilyHandle, ByteBuffer key)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      key - ByteBuffer with key. Must be allocated as direct.
      Returns:
      true if key exist in database, otherwise false.
    • keyExists

      public boolean keyExists(ReadOptions readOptions, ByteBuffer key)
      Check if a key exists in the database. This method is not as lightweight as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      readOptions - ReadOptions instance
      key - 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 as keyMayExist but 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 where keyMayExist may return a false positive. The code crosses the Java/JNI boundary only once.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance
      readOptions - ReadOptions instance
      key - ByteBuffer with key. Must be allocated as direct.
      Returns:
      true if key exist in database, otherwise false.
    • keyMayExist

      public boolean keyMayExist(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 valueHolder must 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 for
      valueHolder - 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, the value will 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(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 valueHolder must 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 for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - the length of the "key" array to be used, must be non-negative and no larger than "key".length
      valueHolder - 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, the value will 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 valueHolder must 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 - ColumnFamilyHandle instance
      key - byte array of a key to search for
      valueHolder - 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, the value will 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 valueHolder must 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 - ColumnFamilyHandle instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - the length of the "key" array to be used, must be non-negative and no larger than "key".length
      valueHolder - 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, the value will 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, 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 valueHolder must 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 - ReadOptions instance
      key - byte array of a key to search for
      valueHolder - 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, the value will 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 valueHolder must 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 - ReadOptions instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - the length of the "key" array to be used, must be non-negative and no larger than "key".length
      valueHolder - 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, the value will 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 valueHolder must 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 - ColumnFamilyHandle instance
      readOptions - ReadOptions instance
      key - byte array of a key to search for
      valueHolder - 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, the value will 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 valueHolder must 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 - ColumnFamilyHandle instance
      readOptions - ReadOptions instance
      key - byte array of a key to search for
      offset - the offset of the "key" array to be used, must be non-negative and no larger than "key".length
      len - the length of the "key" array to be used, must be non-negative and no larger than "key".length
      valueHolder - 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, the value will 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(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:
      key - bytebuffer containing the value of the key
      Returns:
      false if the key definitely does not exist in the database, otherwise true.
    • keyMayExist

      public boolean keyMayExist(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. That is to say that this method is probabilistic and may return false positives, but never a false negative.
      Parameters:
      columnFamilyHandle - the ColumnFamilyHandle to look for the key in
      key - bytebuffer containing the value of the key
      Returns:
      false if the key definitely does not exist in the database, otherwise true.
    • keyMayExist

      public boolean keyMayExist(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:
      readOptions - the ReadOptions to use when reading the key/value
      key - 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(ByteBuffer key, ByteBuffer value)
      If the key definitely does not exist in the database, then this method returns KeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returns KeyMayExist.KeyMayExistEnum.kExistsWithValue otherwise it returns KeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is that KeyMayExist.KeyMayExistEnum.kNotExist is an assurance that the key does not exist.
      Parameters:
      key - bytebuffer containing the value of the key
      value - bytebuffer which will receive a value if the key exists and a value is known
      Returns:
      a KeyMayExist object 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 returns KeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returns KeyMayExist.KeyMayExistEnum.kExistsWithValue otherwise it returns KeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is that KeyMayExist.KeyMayExistEnum.kNotExist is an assurance that the key does not exist.
      Parameters:
      columnFamilyHandle - the ColumnFamilyHandle to look for the key in
      key - bytebuffer containing the value of the key
      value - bytebuffer which will receive a value if the key exists and a value is known
      Returns:
      a KeyMayExist object reporting if key may exist and if a value is provided
    • keyMayExist

      public KeyMayExist keyMayExist(ReadOptions readOptions, ByteBuffer key, ByteBuffer value)
      If the key definitely does not exist in the database, then this method returns KeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returns KeyMayExist.KeyMayExistEnum.kExistsWithValue otherwise it returns KeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is that KeyMayExist.KeyMayExistEnum.kNotExist is an assurance that the key does not exist.
      Parameters:
      readOptions - the ReadOptions to use when reading the key/value
      key - bytebuffer containing the value of the key
      value - bytebuffer which will receive a value if the key exists and a value is known
      Returns:
      a KeyMayExist object 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 - the ColumnFamilyHandle to look for the key in
      readOptions - the ReadOptions to use when reading the key/value
      key - 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 returns KeyMayExist.KeyMayExistEnum.kNotExist, otherwise if it can with best effort retreive the value, it returns KeyMayExist.KeyMayExistEnum.kExistsWithValue otherwise it returns KeyMayExist.KeyMayExistEnum.kExistsWithoutValue. The choice not to return a value which might exist is at the discretion of the implementation; the only guarantee is that KeyMayExist.KeyMayExistEnum.kNotExist is an assurance that the key does not exist.
      Parameters:
      columnFamilyHandle - the ColumnFamilyHandle to look for the key in
      readOptions - the ReadOptions to use when reading the key/value
      key - bytebuffer containing the value of the key
      value - bytebuffer which will receive a value if the key exists and a value is known
      Returns:
      a KeyMayExist object reporting if key may exist and if a value is provided
    • newIterator

      public RocksIterator newIterator()

      Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).

      Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.

      Returns:
      instance of iterator object.
    • newIterator

      public RocksIterator newIterator(ReadOptions readOptions)

      Return a heap-allocated iterator over the contents of the database. The result of newIterator() is initially invalid (caller must call one of the Seek methods on the iterator before using it).

      Caller should close the iterator when it is no longer needed. The returned iterator should be closed before this db is closed.

      Parameters:
      readOptions - ReadOptions instance.
      Returns:
      instance of iterator object.
    • newIterator

      public RocksIterator newIterator(ColumnFamilyHandle columnFamilyHandle)

      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 - ColumnFamilyHandle instance
      Returns:
      instance of iterator object.
    • newIterator

      public RocksIterator newIterator(ColumnFamilyHandle columnFamilyHandle, ReadOptions readOptions)

      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 - ColumnFamilyHandle instance
      readOptions - ReadOptions instance.
      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 - List containing ColumnFamilyHandle instances.
      Returns:
      List containing RocksIterator instances
      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 - List containing ColumnFamilyHandle instances.
      readOptions - ReadOptions instance.
      Returns:
      List containing RocksIterator instances
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • getSnapshot

      public Snapshot getSnapshot()

      Return a handle to the current DB state. Iterators created with this handle will all observe a stable snapshot of the current DB state. The caller must call ReleaseSnapshot(result) when the snapshot is no longer needed.

      nullptr will be returned if the DB fails to take a snapshot or does not support snapshot.

      Returns:
      Snapshot Snapshot instance
    • releaseSnapshot

      public void releaseSnapshot(Snapshot snapshot)
      Release a previously acquired snapshot.

      The caller must not use "snapshot" after this call.

      Parameters:
      snapshot - Snapshot instance
    • 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 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:
      columnFamilyHandle - ColumnFamilyHandle instance, 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

      public String getProperty(String property) throws RocksDBException
      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

      public Map<String,String> getMapProperty(String property) throws RocksDBException
      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 - ColumnFamilyHandle instance, 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

      public long getLongProperty(String property) throws RocksDBException

      Similar to GetProperty(), but only works for a subset of properties whose return value is a numerical value. Return the value as long.

      Note: As the returned property is of type uint64_t on C++ side the returning value can be negative because Java supports in Java 7 only signed long values.

      Java 7: To mitigate the problem of the non existent unsigned long tpye, values should be encapsulated using BigInteger to reflect the correct value. The correct behavior is guaranteed if 2^64 is added to negative values.

      Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type Long.

      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_t on C++ side the returning value can be negative because Java supports in Java 7 only signed long values.

      Java 7: To mitigate the problem of the non existent unsigned long tpye, values should be encapsulated using BigInteger to reflect the correct value. The correct behavior is guaranteed if 2^64 is added to negative values.

      Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type Long.

      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance, or null for the default column family
      property - to be fetched.
      Returns:
      numerical property value
      Throws:
      RocksDBException - if an error happens in the underlying native code.
    • resetStats

      public void resetStats() throws RocksDBException
      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

      public long getAggregatedLongProperty(String property) throws RocksDBException

      Return sum of the getLongProperty of all the column families

      Note: As the returned property is of type uint64_t on C++ side the returning value can be negative because Java supports in Java 7 only signed long values.

      Java 7: To mitigate the problem of the non existent unsigned long tpye, values should be encapsulated using BigInteger to reflect the correct value. The correct behavior is guaranteed if 2^64 is added to negative values.

      Java 8: In Java 8 the value should be treated as unsigned long using provided methods of type Long.

      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 sizeApproximationFlags defines whether the returned size should include the recently written data in the mem-tables (if the mem-table type supports it), data serialized to disk, or both.

      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance, or null for the default column family
      ranges - the ranges over which to approximate sizes
      sizeApproximationFlags - 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 sizeApproximationFlags defines whether the returned size should include the recently written data in the mem-tables (if the mem-table type supports it), data serialized to disk, or both.

      Parameters:
      ranges - the ranges over which to approximate sizes
      sizeApproximationFlags - 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 to getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance, or null for the default column family
      range - the ranges over which to get the memtable stats
      Returns:
      the count and size for the range
    • getApproximateMemTableStats

      public RocksDB.CountAndSize getApproximateMemTableStats(Range range)
      This method is similar to getApproximateSizes(ColumnFamilyHandle, List, SizeApproximationFlag...), except that it returns approximate number of records and size in memtables.
      Parameters:
      range - the ranges over which to get the memtable stats
      Returns:
      the count and size for the range
    • compactRange

      public void compactRange() throws RocksDBException

      Range compaction of database.

      Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.

      See also

      Throws:
      RocksDBException - thrown if an error occurs within the native part of the library.
    • compactRange

      public void compactRange(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException

      Range compaction of column family.

      Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.

      See also

      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance, or null for the default column family.
      Throws:
      RocksDBException - thrown if an error occurs within the native part of the library.
    • compactRange

      public void compactRange(byte[] begin, byte[] end) throws RocksDBException

      Range compaction of database.

      Note: After the database has been compacted, all data will have been pushed down to the last level containing any data.

      See also

      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 - ColumnFamilyHandle instance, or null for the default column family.
      begin - start of key range (included in range)
      end - end of key range (excluded from range)
      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 - ColumnFamilyHandle instance.
      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 - ColumnFamilyHandle instance
      beginKey - 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 - ColumnFamilyHandle instance, or null for the default column family.
      mutableColumnFamilyOptions - the options.
      Throws:
      RocksDBException - if an error occurs whilst setting the options
    • setPerfLevel

      public void setPerfLevel(PerfLevel level)
      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

      public PerfLevel getPerfLevel()
      Return current performance level measurement settings.
      Returns:
    • getPerfContext

      public PerfContext getPerfContext()
      Return perf context bound to this thread.
      Returns:
    • getOptions

      Get the options for the column family handle
      Parameters:
      columnFamilyHandle - ColumnFamilyHandle instance, 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

      Default 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

      public void setDBOptions(MutableDBOptions mutableDBoptions) throws RocksDBException
      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 options
      inputFileNames - the name of the files to compact
      outputLevel - the level to which they should be compacted
      outputPathId - the id of the output path, or -1
      compactionJobInfo - 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 options
      columnFamilyHandle - columnFamilyHandle, or null for the default column family
      inputFileNames - the name of the files to compact
      outputLevel - the level to which they should be compacted
      outputPathId - the id of the output path, or -1
      compactionJobInfo - 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

      public void pauseBackgroundWork() throws RocksDBException
      This function will wait until all currently running background processes finish. After it returns, no background process will be run until continueBackgroundWork() is called
      Throws:
      RocksDBException - if an error occurs when pausing background work
    • continueBackgroundWork

      public void continueBackgroundWork() throws RocksDBException
      Resumes background work which was suspended by previously calling pauseBackgroundWork()
      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

      public int numberLevels(ColumnFamilyHandle columnFamilyHandle)
      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

      public int maxMemCompactionLevel(ColumnFamilyHandle columnFamilyHandle)
      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

      public int level0StopWriteTrigger(ColumnFamilyHandle columnFamilyHandle)
      Number of files in level-0 that would stop writes.
      Parameters:
      columnFamilyHandle - the column family handle
      Returns:
      the number of files
    • getName

      public String getName()
      Get DB name -- the exact same name that was provided as an argument to as path to open(Options, String).
      Returns:
      the DB name
    • getEnv

      public Env getEnv()
      Get the Env object from the DB
      Returns:
      the env
    • flush

      public void flush(FlushOptions flushOptions) throws RocksDBException

      Flush all memory table data.

      Note: it must be ensured that the FlushOptions instance is not GC'ed before this method finishes. If the wait parameter is set to false, flush processing is asynchronous.

      Parameters:
      flushOptions - FlushOptions instance.
      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 - FlushOptions instance.
      columnFamilyHandle - ColumnFamilyHandle instance.
      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 - FlushOptions instance.
      columnFamilyHandles - column family handles.
      Throws:
      RocksDBException - thrown if an error occurs within the native part of the library.
    • flushWal

      public void flushWal(boolean sync) throws RocksDBException
      Flush the WAL memory buffer to the file. If sync is true, it calls syncWal() afterwards.
      Parameters:
      sync - true to also fsync to disk.
      Throws:
      RocksDBException - if an error occurs whilst flushing
    • syncWal

      public void syncWal() throws RocksDBException
      Sync the WAL.

      Note that write(WriteOptions, WriteBatch) followed by #syncWal() is not exactly the same as write(WriteOptions, WriteBatch) with WriteOptions.sync() set to true; In the latter case the changes won't be visible until the sync is done.

      Currently only works if Options.allowMmapWrites() is set to false.

      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

      public void disableFileDeletions() throws RocksDBException

      Prevent file deletions. Compactions will continue to occur, but no obsolete files will be deleted. Calling this multiple times have the same effect as calling it once.

      Throws:
      RocksDBException - thrown if operation was not performed successfully.
    • enableFileDeletions

      public void enableFileDeletions() throws RocksDBException

      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

      public RocksDB.LiveFiles getLiveFiles() throws RocksDBException
      Retrieve the list of all files in the database after flushing the memtable.

      See getLiveFiles(boolean).

      Returns:
      the live files
      Throws:
      RocksDBException - if an error occurs whilst retrieving the list of live files
    • getLiveFiles

      public RocksDB.LiveFiles getLiveFiles(boolean flushMemtable) throws RocksDBException
      Retrieve the list of all files in the database.

      In case you have multiple column families, even if flushMemtable is true, you still need to call getSortedWalFiles() after #getLiveFiles(boolean) to compensate for new data that arrived to already-flushed column families while other column families were flushing.

      NOTE: Calling #getLiveFiles(boolean) followed by getSortedWalFiles() can generate a lossless backup.

      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

      public List<LogFile> getSortedWalFiles() throws RocksDBException
      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

      public TransactionLogIterator getUpdatesSince(long sequenceNumber) throws RocksDBException

      Returns an iterator that is positioned at a write-batch containing seq_number. If the sequence number is non existent, it returns an iterator at the first available seq_no after the requested seq_no.

      Must set WAL_ttl_seconds or WAL_size_limit_MB to large values to use this api, else the WAL files will get cleared aggressively and the iterator might keep getting invalid before an update is read.

      Parameters:
      sequenceNumber - sequence number offset
      Returns:
      TransactionLogIterator instance.
      Throws:
      RocksDBException - if iterator cannot be retrieved from native-side.
    • deleteFile

      public void deleteFile(String name) throws RocksDBException
      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

      public List<LiveFileMetaData> getLiveFilesMetaData()
      Gets a list of all table files metadata.
      Returns:
      table files metadata.
    • getColumnFamilyMetaData

      public ColumnFamilyMetaData getColumnFamilyMetaData(ColumnFamilyHandle columnFamilyHandle)
      Obtains the meta data of the specified column family of the DB.
      Parameters:
      columnFamilyHandle - the column family
      Returns:
      the column family metadata
    • getColumnFamilyMetaData

      public ColumnFamilyMetaData 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 ingest
      ingestExternalFileOptions - 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 files
      filePathList - The list of files to ingest
      ingestExternalFileOptions - the options for the ingestion
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • verifyChecksum

      public void verifyChecksum() throws RocksDBException
      Verify checksum
      Throws:
      RocksDBException - if the checksum is not valid
    • getDefaultColumnFamily

      public ColumnFamilyHandle getDefaultColumnFamily()
      Gets the handle for the default column family
      Returns:
      The handle of the default column family
    • makeDefaultColumnFamilyHandle

      protected ColumnFamilyHandle 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

      public Map<String,TableProperties> getPropertiesOfAllTables() throws RocksDBException
      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

      public Range suggestCompactRange(ColumnFamilyHandle columnFamilyHandle) throws RocksDBException
      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

      public Range suggestCompactRange() throws RocksDBException
      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

      public void promoteL0(int targetLevel) throws RocksDBException
      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 options
      traceWriter - the trace writer
      Throws:
      RocksDBException - if an error occurs whilst starting the trace
    • endTrace

      public void endTrace() throws RocksDBException
      Stop tracing DB operations.

      See startTrace(TraceOptions, AbstractTraceWriter)

      Throws:
      RocksDBException - if an error occurs whilst ending the trace
    • tryCatchUpWithPrimary

      public void tryCatchUpWithPrimary() throws RocksDBException
      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

      public static void destroyDB(String path, Options options) throws RocksDBException
      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 - Options instance.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • storeOptionsInstance

      protected void storeOptionsInstance(DBOptionsInterface<?> options)
    • storeDefaultColumnFamilyHandle

      protected void storeDefaultColumnFamilyHandle(ColumnFamilyHandle columnFamilyHandle)
    • disposeInternal

      protected void disposeInternal(long handle)
      Specified by:
      disposeInternal in class RocksObject