Package org.rocksdb
Class Slice
java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.RocksMutableObject
org.rocksdb.AbstractSlice<byte[]>
org.rocksdb.Slice
- All Implemented Interfaces:
AutoCloseable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the backing sliceprotected final byte[]data0(long handle) Access to the data is provided by the subtype as it needs to handle the generic typing.protected voidDeletes underlying C++ slice pointer and any buffered data.voidremovePrefix(int n) Drops the specifiednnumber of bytes from the start of the backing sliceMethods 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
-
Constructor Details
-
Slice
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 Details
-
clear
public void clear()Description copied from class:AbstractSliceClears the backing slice- Specified by:
clearin classAbstractSlice<byte[]>
-
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<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:
disposeInternalin classRocksMutableObject
-
data0
protected final byte[] 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<byte[]>- Parameters:
handle- The address of the underlying native object.- Returns:
- Java typed access to the data.
-