Package org.rocksdb

Class SstFileWriter

All Implemented Interfaces:
AutoCloseable

public class SstFileWriter extends RocksObject
SstFileWriter is used to create sst files that can be added to the database later. All keys in files generated by SstFileWriter will have sequence number = 0.
  • Constructor Details

    • SstFileWriter

      public SstFileWriter(EnvOptions envOptions, Options options)
      SstFileWriter Constructor.
      Parameters:
      envOptions - EnvOptions instance.
      options - Options instance.
  • Method Details

    • open

      public void open(String filePath) throws RocksDBException
      Prepare SstFileWriter to write to a file.
      Parameters:
      filePath - the location of file
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • put

      public void put(Slice key, Slice value) throws RocksDBException
      Add a Put key with value to currently opened file.
      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(DirectSlice key, DirectSlice value) throws RocksDBException
      Add a Put key with value to currently opened file.
      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(ByteBuffer key, ByteBuffer value) throws RocksDBException
      Add a Put key with value to currently opened file.
      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, byte[] value) throws RocksDBException
      Add a Put key with value to currently opened file.
      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.
    • merge

      public void merge(Slice key, Slice value) throws RocksDBException
      Add a Merge key with value to currently opened file.
      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, byte[] value) throws RocksDBException
      Add a Merge key with value to currently opened file.
      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(DirectSlice key, DirectSlice value) throws RocksDBException
      Add a Merge key with value to currently opened file.
      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.
    • delete

      public void delete(Slice key) throws RocksDBException
      Add a deletion key to currently opened file.
      Parameters:
      key - the specified key to be deleted.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • delete

      public void delete(DirectSlice key) throws RocksDBException
      Add a deletion key to currently opened file.
      Parameters:
      key - the specified key to be deleted.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • delete

      public void delete(byte[] key) throws RocksDBException
      Add a deletion key to currently opened file.
      Parameters:
      key - the specified key to be deleted.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • finish

      public void finish() throws RocksDBException
      Finish the process and close the sst file.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • fileSize

      public long fileSize() throws RocksDBException
      Return the current file size.
      Returns:
      the current file size.
      Throws:
      RocksDBException - thrown if error happens in underlying native library.
    • disposeInternal

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