public abstract class AbstractSlice<T> extends RocksMutableObject
This class is package private, implementers should extend either of the public abstract classes:
Slice,
Regards the lifecycle of Java Slices in RocksDB:
At present when you configure a Comparator from Java, it creates an
instance of a C++ BaseComparatorJniCallback subclass and
passes that to RocksDB as the comparator. That subclass of
BaseComparatorJniCallback creates the Java,
subclass Objects. When you dispose
the Java @see org.rocksdb.AbstractComparator subclass, it disposes the
C++ BaseComparatorJniCallback subclass, which in turn destroys the
Java @see org.rocksdb.AbstractSlice subclass Objects.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSlice() |
protected |
AbstractSlice(long nativeHandle) |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
clear()
Clears the backing slice
|
int |
compare(AbstractSlice<?> other)
Three-way key comparison
|
protected static long |
createNewSliceFromString(java.lang.String str) |
T |
data()
Returns the data of the slice.
|
protected abstract T |
data0(long handle)
Access to the data is provided by the
subtype as it needs to handle the
generic typing.
|
protected void |
disposeInternal(long handle)
Deletes underlying C++ slice pointer.
|
boolean |
empty()
Return true if the length of the
data is zero.
|
boolean |
equals(java.lang.Object other)
If other is a slice object, then
we defer to
compare
to check equality, otherwise we return false. |
int |
hashCode() |
abstract void |
removePrefix(int n)
Drops the specified
n
number of bytes from the start
of the backing slice |
int |
size()
Return the length (in bytes) of the data.
|
boolean |
startsWith(AbstractSlice<?> prefix)
Determines whether this slice starts with
another slice
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean hex)
Creates a string representation of the data
|
close, disposeInternal, getNativeHandle, isOwningHandle, resetNativeHandle, setNativeHandleprotected AbstractSlice()
protected AbstractSlice(long nativeHandle)
public T data()
data0(long)protected abstract T data0(long handle)
handle - The address of the underlying
native object.public abstract void removePrefix(int n)
n
number of bytes from the start
of the backing slicen - The number of bytes to droppublic abstract void clear()
public int size()
public boolean empty()
public java.lang.String toString(boolean hex)
hex - When true, the representation
will be encoded in hexadecimal.public java.lang.String toString()
toString in class java.lang.Objectpublic int compare(AbstractSlice<?> other)
other - A slice to compare againstpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
compare
to check equality, otherwise we return false.equals in class java.lang.Objectother - Object to test for equalitythis.compare(other) == 0,
false otherwise.public boolean startsWith(AbstractSlice<?> prefix)
prefix - Another slice which may of may not
be a prefix of this slice.prefix sliceprotected static long createNewSliceFromString(java.lang.String str)
protected final void disposeInternal(long handle)
disposeInternal in class RocksMutableObject