Package org.rocksdb
Class Slice
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.RocksMutableObject
-
- org.rocksdb.AbstractSlice<byte[]>
-
- org.rocksdb.Slice
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Slice extends AbstractSlice<byte[]>
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 Constructor Description Slice(byte[] data)Constructs a slice where the data is a copy of the byte array.Slice(byte[] data, int offset)Constructs a slice where the data is a copy of the byte array from a specific offset.Slice(java.lang.String str)Constructs a slice where the data is taken from a String.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the backing sliceprotected byte[]data0(long handle)Access to the data is provided by the subtype as it needs to handle the generic typing.protected voiddisposeInternal()Deletes underlying C++ slice pointer and any buffered data.voidremovePrefix(int n)Drops the specifiednnumber of bytes from the start of the backing slice-
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
-
-
-
-
Constructor Detail
-
Slice
public Slice(java.lang.String str)
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 Detail
-
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.
-
-