Package org.rocksdb
Class DirectSlice
- All Implemented Interfaces:
AutoCloseable
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 -
Constructor Summary
ConstructorsConstructorDescriptionDirectSlice(String str) Constructs a slice where the data is taken from a String.DirectSlice(ByteBuffer data) Constructs a slice where the data is read from the provided ByteBufferDirectSlice(ByteBuffer data, int length) Constructs a slice where the data is read from the provided ByteBuffer up to a certain length -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the backing sliceprotected final ByteBufferdata0(long handle) Access to the data is provided by the subtype as it needs to handle the generic typing.protected voidbyteget(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, toStringMethods inherited from class org.rocksdb.RocksMutableObject
close, getNativeHandle, isOwningHandle, resetNativeHandle, setNativeHandle
-
Field Details
-
NONE
-
-
Constructor Details
-
DirectSlice
Constructs a slice where the data is taken from a String.- Parameters:
str- The string
-
DirectSlice
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
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:AbstractSliceClears the backing slice- Specified by:
clearin classAbstractSlice<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<ByteBuffer>- Parameters:
n- The number of bytes to drop
-
setLength
public void setLength(int n) -
disposeInternal
protected void disposeInternal()- Overrides:
disposeInternalin classRocksMutableObject
-
data0
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<ByteBuffer>- Parameters:
handle- The address of the underlying native object.- Returns:
- Java typed access to the data.
-