Package org.rocksdb

Class Slice

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Slice
    extends AbstractSlice<byte[]>

    Base class for slices which will receive byte[] based access to the underlying data.

    byte[] backed slices typically perform better with small keys and values. When using larger keys and values consider using DirectSlice

    • Constructor Detail

      • Slice

        public Slice​(java.lang.String str)

        Constructs a slice where the data is taken from a String.

        Parameters:
        str - String value.
      • Slice

        public Slice​(byte[] data,
                     int offset)

        Constructs a slice where the data is a copy of the byte array from a specific offset.

        Parameters:
        data - byte array.
        offset - offset within the byte array.
      • Slice

        public Slice​(byte[] data)

        Constructs a slice where the data is a copy of the byte array.

        Parameters:
        data - byte array.
    • Method Detail

      • removePrefix

        public void removePrefix​(int n)
        Description copied from class: AbstractSlice
        Drops the specified n number of bytes from the start of the backing slice
        Specified by:
        removePrefix in class AbstractSlice<byte[]>
        Parameters:
        n - The number of bytes to drop
      • disposeInternal

        protected void disposeInternal()

        Deletes underlying C++ slice pointer and any buffered data.

        Note that this function should be called only after all RocksDB instances referencing the slice are closed. Otherwise an undefined behavior will occur.

        Overrides:
        disposeInternal in class RocksMutableObject
      • data0

        protected final byte[] data0​(long handle)
        Description copied from class: AbstractSlice
        Access to the data is provided by the subtype as it needs to handle the generic typing.
        Specified by:
        data0 in class AbstractSlice<byte[]>
        Parameters:
        handle - The address of the underlying native object.
        Returns:
        Java typed access to the data.