Package org.rocksdb

Class DirectSlice

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class DirectSlice
    extends AbstractSlice<java.nio.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
    • Constructor Detail

      • DirectSlice

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

        public DirectSlice​(java.nio.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​(java.nio.ByteBuffer data)
        Constructs a slice where the data is read from the provided ByteBuffer
        Parameters:
        data - The bugger containing the data
    • Method Detail

      • 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<java.nio.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<java.nio.ByteBuffer>
        Parameters:
        n - The number of bytes to drop
      • setLength

        public void setLength​(int n)
      • data0

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