public class DirectSlice extends RocksObject
Modifier and Type | Field and Description |
---|---|
static DirectSlice |
NONE |
nativeHandle_
Constructor and Description |
---|
DirectSlice(java.nio.ByteBuffer data)
Constructs a slice where the data is
read from the provided
ByteBuffer
|
DirectSlice(java.nio.ByteBuffer data,
int length)
Constructs a slice where the data is
read from the provided
ByteBuffer up to a certain length
|
DirectSlice(java.lang.String str)
Constructs a slice
where the data is taken from
a String.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the backing slice
|
int |
compare(org.rocksdb.AbstractSlice<?> other)
Three-way key comparison
|
protected void |
createNewSliceFromString(java.lang.String str) |
T |
data()
Returns the data of the slice.
|
protected java.nio.ByteBuffer |
data0(long handle)
Access to the data is provided by the
subtype as it needs to handle the
generic typing.
|
protected void |
disposeInternal()
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. |
byte |
get(int offset)
Retrieves the byte at a specific offset
from the underlying data
|
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(org.rocksdb.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
|
disOwnNativeHandle, dispose, finalize, isInitialized, isOwningNativeHandle
public static final DirectSlice NONE
public DirectSlice(java.lang.String str)
str
- The stringpublic DirectSlice(java.nio.ByteBuffer data, int length)
data
- The buffer containing the datalength
- The length of the data to use for the slicepublic DirectSlice(java.nio.ByteBuffer data)
data
- The bugger containing the datapublic byte get(int offset)
offset
- The (zero-based) offset of the byte to retrievepublic void clear()
public void removePrefix(int n)
n
number of bytes from the start
of the backing slicen
- The number of bytes to dropprotected final java.nio.ByteBuffer data0(long handle)
handle
- The address of the underlying
native object.public T data()
AbstractSlice.data0(long)
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.Object
public int compare(org.rocksdb.AbstractSlice<?> other)
other
- A slice to compare againstpublic boolean equals(java.lang.Object other)
compare
to check equality, otherwise we return false.equals
in class java.lang.Object
other
- Object to test for equalitythis.compare(other) == 0
,
false otherwise.public boolean startsWith(org.rocksdb.AbstractSlice<?> prefix)
prefix
- Another slice which may of may not
be a prefix of this slice.prefix
sliceprotected void disposeInternal()
disposeInternal
in class RocksObject
protected void createNewSliceFromString(java.lang.String str)