Package org.rocksdb

Class SstFileWriter

  • All Implemented Interfaces:
    java.lang.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 Detail

      • SstFileWriter

        @Deprecated
        public SstFileWriter​(EnvOptions envOptions,
                             Options options,
                             AbstractComparator comparator)
        Deprecated.
        Use SstFileWriter(EnvOptions, Options). Passing an explicit comparator is deprecated in lieu of passing the comparator as part of options. Use the other constructor instead.
        SstFileWriter Constructor.
        Parameters:
        envOptions - EnvOptions instance.
        options - Options instance.
        comparator - the comparator to specify the ordering of keys.
      • SstFileWriter

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

      • open

        public void open​(java.lang.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.
      • add

        @Deprecated
        public void add​(Slice key,
                        Slice value)
                 throws RocksDBException
        Deprecated.
        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​(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​(java.nio.ByteBuffer key,
                        java.nio.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.
        Throws:
        RocksDBException - thrown if error happens in underlying native library.