Package org.rocksdb
Class AbstractSlice<T>
java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.RocksMutableObject
org.rocksdb.AbstractSlice<T>
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
DirectSlice,Slice
Slices are used by RocksDB to provide
efficient access to keys and values.
This class is package private, implementers should extend either of the public abstract classes:
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclear()Clears the backing sliceintcompare(AbstractSlice<?> other) Three-way key comparisonprotected static longdata()Returns the data of the slice.protected abstract Tdata0(long handle) Access to the data is provided by the subtype as it needs to handle the generic typing.protected final voiddisposeInternal(long handle) Deletes underlying C++ slice pointer.booleanempty()Return true if the length of the data is zero.booleanIf other is a slice object, then we defer tocompareto check equality, otherwise we return false.inthashCode()abstract voidremovePrefix(int n) Drops the specifiednnumber of bytes from the start of the backing sliceintsize()Return the length (in bytes) of the data.booleanstartsWith(AbstractSlice<?> prefix) Determines whether this slice starts with another slicetoString()toString(boolean hex) Creates a string representation of the dataMethods inherited from class org.rocksdb.RocksMutableObject
close, disposeInternal, getNativeHandle, isOwningHandle, resetNativeHandle, setNativeHandle
-
Constructor Details
-
AbstractSlice
protected AbstractSlice() -
AbstractSlice
protected AbstractSlice(long nativeHandle)
-
-
Method Details
-
data
Returns the data of the slice.- Returns:
- The slice data. Note, the type of access is determined by the subclass
- See Also:
-
data0
Access to the data is provided by the subtype as it needs to handle the generic typing.- Parameters:
handle- The address of the underlying native object.- Returns:
- Java typed access to the data.
-
removePrefix
public abstract void removePrefix(int n) Drops the specifiednnumber of bytes from the start of the backing slice- Parameters:
n- The number of bytes to drop
-
clear
public abstract void clear()Clears the backing slice -
size
public int size()Return the length (in bytes) of the data.- Returns:
- The length in bytes.
-
empty
public boolean empty()Return true if the length of the data is zero.- Returns:
- true if there is no data, false otherwise.
-
toString
Creates a string representation of the data- Parameters:
hex- When true, the representation will be encoded in hexadecimal.- Returns:
- The string representation of the data.
-
toString
-
compare
Three-way key comparison- Parameters:
other- A slice to compare against- Returns:
- Should return either: 1) < 0 if this < other 2) == 0 if this == other 3) > 0 if this > other
-
hashCode
public int hashCode() -
equals
If other is a slice object, then we defer tocompareto check equality, otherwise we return false. -
startsWith
Determines whether this slice starts with another slice- Parameters:
prefix- Another slice which may of may not be a prefix of this slice.- Returns:
- true when this slice starts with the
prefixslice
-
createNewSliceFromString
-
disposeInternal
protected final void disposeInternal(long handle) Deletes underlying C++ slice pointer. Note that this function should be called only after all RocksDB instances referencing the slice are closed. Otherwise, an undefined behavior will occur.- Specified by:
disposeInternalin classRocksMutableObject
-