Package org.rocksdb

Class DirectSlice

All Implemented Interfaces:
AutoCloseable

public class DirectSlice extends AbstractSlice<ByteBuffer>
Base class for slices which will receive direct ByteBuffer based access to the underlying data.

ByteBuffer backed slices typically perform better with larger keys and values. When using smaller keys and values consider using @see org.rocksdb.Slice

  • Field Details

  • Constructor Details

    • DirectSlice

      public DirectSlice(String str)
      Constructs a slice where the data is taken from a String.
      Parameters:
      str - The string
    • DirectSlice

      public DirectSlice(ByteBuffer data, int length)
      Constructs a slice where the data is read from the provided ByteBuffer up to a certain length
      Parameters:
      data - The buffer containing the data
      length - The length of the data to use for the slice
    • DirectSlice

      public DirectSlice(ByteBuffer data)
      Constructs a slice where the data is read from the provided ByteBuffer
      Parameters:
      data - The bugger containing the data
  • Method Details

    • get

      public byte get(int offset)
      Retrieves the byte at a specific offset from the underlying data
      Parameters:
      offset - The (zero-based) offset of the byte to retrieve
      Returns:
      the requested byte
    • clear

      public void clear()
      Description copied from class: AbstractSlice
      Clears the backing slice
      Specified by:
      clear in class AbstractSlice<ByteBuffer>
    • 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<ByteBuffer>
      Parameters:
      n - The number of bytes to drop
    • setLength

      public void setLength(int n)
    • disposeInternal

      protected void disposeInternal()
      Overrides:
      disposeInternal in class RocksMutableObject
    • data0

      protected final ByteBuffer 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<ByteBuffer>
      Parameters:
      handle - The address of the underlying native object.
      Returns:
      Java typed access to the data.