Package org.rocksdb
Class DirectSlice
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.RocksMutableObject
-
- org.rocksdb.AbstractSlice<java.nio.ByteBuffer>
-
- org.rocksdb.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
-
-
Field Summary
Fields Modifier and Type Field Description static DirectSliceNONE
-
Constructor Summary
Constructors Constructor Description DirectSlice(java.lang.String str)Constructs a slice where the data is taken from a String.DirectSlice(java.nio.ByteBuffer data)Constructs a slice where the data is read from the provided ByteBufferDirectSlice(java.nio.ByteBuffer data, int length)Constructs a slice where the data is read from the provided ByteBuffer up to a certain length
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the backing sliceprotected java.nio.ByteBufferdata0(long handle)Access to the data is provided by the subtype as it needs to handle the generic typing.protected voiddisposeInternal()byteget(int offset)Retrieves the byte at a specific offset from the underlying datavoidremovePrefix(int n)Drops the specifiednnumber of bytes from the start of the backing slicevoidsetLength(int n)-
Methods inherited from class org.rocksdb.AbstractSlice
compare, createNewSliceFromString, data, disposeInternal, empty, equals, hashCode, size, startsWith, toString, toString
-
Methods inherited from class org.rocksdb.RocksMutableObject
close, getNativeHandle, isOwningHandle, resetNativeHandle, setNativeHandle
-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Field Detail
-
NONE
public static final DirectSlice NONE
-
-
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 datalength- 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:AbstractSliceClears the backing slice- Specified by:
clearin classAbstractSlice<java.nio.ByteBuffer>
-
removePrefix
public void removePrefix(int n)
Description copied from class:AbstractSliceDrops the specifiednnumber of bytes from the start of the backing slice- Specified by:
removePrefixin classAbstractSlice<java.nio.ByteBuffer>- Parameters:
n- The number of bytes to drop
-
setLength
public void setLength(int n)
-
disposeInternal
protected void disposeInternal()
- Overrides:
disposeInternalin classRocksMutableObject
-
data0
protected final java.nio.ByteBuffer data0(long handle)
Description copied from class:AbstractSliceAccess to the data is provided by the subtype as it needs to handle the generic typing.- Specified by:
data0in classAbstractSlice<java.nio.ByteBuffer>- Parameters:
handle- The address of the underlying native object.- Returns:
- Java typed access to the data.
-
-