V
- the backing typepublic interface ValueAccessor<V>
Buffer.position()
and having a length of Buffer.remaining()
. ValueAccessor
implementations need to maintain this internally. ValueAccessors should also never modify the state of the
byte buffers view (ie: offset, limit). This would also apply to value accessors for simlilar types
(ie: netty's ByteBuf}.Modifier and Type | Interface and Description |
---|---|
static interface |
ValueAccessor.ObjectFactory<V>
Creates db objects using the given accessors value type.
|
Modifier and Type | Method and Description |
---|---|
V |
allocate(int size)
Allocate and return a instance of bytes on the heap.
|
static <L,R> int |
compare(L left,
ValueAccessor<L> leftAccessor,
R right,
ValueAccessor<R> rightAccessor)
lexicographically compare to
|
<VR> int |
compare(V left,
VR right,
ValueAccessor<VR> accessorR)
lexicographically compare to
|
int |
compareByteArrayTo(byte[] left,
V right)
compare a byte array on the left with a on the right}
|
int |
compareByteBufferTo(java.nio.ByteBuffer left,
V right)
compare a byte buffer on the left with a on the right}
|
<V2> V |
convert(V2 src,
ValueAccessor<V2> accessor)
Convert the data in to
and the returned value may share a common byte array instance, so caller should
assume that modifying the returned value will also modify the contents of
|
int |
copyByteArrayTo(byte[] src,
int srcOffset,
V dst,
int dstOffset,
int size)
copies a byte array into this accessors value.
|
int |
copyByteBufferTo(java.nio.ByteBuffer src,
int srcOffset,
V dst,
int dstOffset,
int size)
copies a byte buffer into this accessors value.
|
<V2> int |
copyTo(V src,
int srcOffset,
V2 dst,
ValueAccessor<V2> dstAccessor,
int dstOffset,
int size)
copy the bytes from the value, starting at the offset into
the value, starting at the offset , using the accessor
|
V[] |
createArray(int length)
allocate an instance of the accessors backing type
|
default void |
digest(V value,
Digest digest)
updates with te contents of
|
void |
digest(V value,
int offset,
int size,
Digest digest)
updates with bytes from the contents of starting
at offset
|
V |
empty()
return a value with a length of 0
|
static <L,R> boolean |
equals(L left,
ValueAccessor<L> leftAccessor,
R right,
ValueAccessor<R> rightAccessor) |
ValueAccessor.ObjectFactory<V> |
factory()
returns the
ValueAccessor.ObjectFactory for the backing type |
default boolean |
getBoolean(V value,
int offset)
returns a boolean from offset
|
byte |
getByte(V value,
int offset)
returns a byte from offset
|
int |
getInt(V value,
int offset)
returns an int from offset
|
long |
getLong(V value,
int offset)
returns a long from offset
|
short |
getShort(V value,
int offset)
returns a short from offset
|
int |
getUnsignedShort(V value,
int offset)
returns an unsigned short from offset
|
default int |
hashCode(V value) |
default boolean |
isEmpty(V value) |
default boolean |
isEmptyFromOffset(V value,
int offset) |
int |
putInt(V dst,
int offset,
int value)
writes the int value to at offset
|
int |
putLong(V dst,
int offset,
long value)
writes the long value to at offset
|
int |
putShort(V dst,
int offset,
short value)
writes the short value to at offset
|
V |
read(DataInputPlus in,
int length)
Reads a value of bytes from
|
int |
size(V value) |
default int |
sizeFromOffset(V value,
int offset) |
default int |
sizeWithShortLength(V value)
serialized size including a short length prefix
|
default int |
sizeWithVIntLength(V value)
serializes size including a vint length prefix
|
V |
slice(V input,
int offset,
int length)
Returns a value with the contents of from to .
|
default V |
sliceWithShortLength(V input,
int offset)
same as
slice(Object, int, int) , except the length is taken from the first
2 bytes from the given offset (and not included in the return value) |
byte[] |
toArray(V value)
returns a byte[] with the contents of
Depending on the accessor implementation, this method may:
* allocate a new byte[] object and copy data into it
* return the value, if the backing type is byte[]
|
byte[] |
toArray(V value,
int offset,
int length)
returns a byte[] with bytes copied from the contents of
starting at offset .
|
java.nio.ByteBuffer |
toBuffer(V value)
returns a ByteBuffer with the contents of
Depending on the accessor implementation, this method may:
* allocate a new ByteBuffer and copy data into it
* return the value, if the backing type is a bytebuffer
|
byte |
toByte(V value)
returns a byte from offset 0
|
double |
toDouble(V value)
returns a double from offset 0
|
float |
toFloat(V value)
returns a float from offset 0
|
java.lang.String |
toHex(V value) |
int |
toInt(V value)
returns an int from offset 0
|
long |
toLong(V value)
returns a long from offset 0
|
short |
toShort(V value)
returns a short from offset 0
|
default java.lang.String |
toString(V value) |
java.lang.String |
toString(V value,
java.nio.charset.Charset charset) |
java.util.UUID |
toUUID(V value)
returns a UUID from offset 0
|
V |
valueOf(boolean v)
return a value with the bytes from
|
V |
valueOf(byte v)
return a value with the bytes from
|
V |
valueOf(byte[] bytes)
return a value containing the
Caller should assume that modifying the returned value
will also modify the contents of
|
V |
valueOf(java.nio.ByteBuffer bytes)
return a value containing the
and the returned value may share a common byte array instance, so caller should
assume that modifying the returned value will also modify the contents of
|
V |
valueOf(double v)
return a value with the bytes from
|
V |
valueOf(float v)
return a value with the bytes from
|
V |
valueOf(int v)
return a value with the bytes from
|
V |
valueOf(long v)
return a value with the bytes from
|
V |
valueOf(short v)
return a value with the bytes from
|
V |
valueOf(java.lang.String s,
java.nio.charset.Charset charset)
return a value containing the bytes for the given string and charset
|
V |
valueOf(java.util.UUID v)
return a value with the bytes from
|
void |
write(V value,
java.nio.ByteBuffer out)
Write the contents of the given value into the ByteBuffer
|
void |
write(V value,
DataOutputPlus out)
Write the contents of the given value into the a DataOutputPlus
|
default void |
writeWithVIntLength(V value,
DataOutputPlus out) |
int size(V value)
default int sizeWithVIntLength(V value)
default int sizeWithShortLength(V value)
default boolean isEmpty(V value)
default int sizeFromOffset(V value, int offset)
default boolean isEmptyFromOffset(V value, int offset)
V[] createArray(int length)
length
- size of backing typ to allocatevoid write(V value, DataOutputPlus out) throws java.io.IOException
java.io.IOException
default void writeWithVIntLength(V value, DataOutputPlus out) throws java.io.IOException
java.io.IOException
void write(V value, java.nio.ByteBuffer out)
<V2> int copyTo(V src, int srcOffset, V2 dst, ValueAccessor<V2> dstAccessor, int dstOffset, int size)
V2
- the destination value typeint copyByteArrayTo(byte[] src, int srcOffset, V dst, int dstOffset, int size)
int copyByteBufferTo(java.nio.ByteBuffer src, int srcOffset, V dst, int dstOffset, int size)
void digest(V value, int offset, int size, Digest digest)
V read(DataInputPlus in, int length) throws java.io.IOException
java.io.IOException
V slice(V input, int offset, int length)
default V sliceWithShortLength(V input, int offset)
slice(Object, int, int)
, except the length is taken from the first
2 bytes from the given offset (and not included in the return value)<VR> int compare(V left, VR right, ValueAccessor<VR> accessorR)
VR
- backing type ofint compareByteArrayTo(byte[] left, V right)
int compareByteBufferTo(java.nio.ByteBuffer left, V right)
default int hashCode(V value)
java.nio.ByteBuffer toBuffer(V value)
byte[] toArray(V value)
byte[] toArray(V value, int offset, int length)
java.lang.String toString(V value, java.nio.charset.Charset charset) throws java.nio.charset.CharacterCodingException
java.nio.charset.CharacterCodingException
default java.lang.String toString(V value) throws java.nio.charset.CharacterCodingException
java.nio.charset.CharacterCodingException
java.lang.String toHex(V value)
default boolean getBoolean(V value, int offset)
byte toByte(V value)
byte getByte(V value, int offset)
short toShort(V value)
short getShort(V value, int offset)
int getUnsignedShort(V value, int offset)
int toInt(V value)
int getInt(V value, int offset)
long toLong(V value)
long getLong(V value, int offset)
float toFloat(V value)
double toDouble(V value)
java.util.UUID toUUID(V value)
int putShort(V dst, int offset, short value)
int putInt(V dst, int offset, int value)
int putLong(V dst, int offset, long value)
V empty()
V valueOf(byte[] bytes)
V valueOf(java.nio.ByteBuffer bytes)
V valueOf(java.lang.String s, java.nio.charset.Charset charset)
V valueOf(java.util.UUID v)
V valueOf(boolean v)
V valueOf(byte v)
V valueOf(short v)
V valueOf(int v)
V valueOf(long v)
V valueOf(float v)
V valueOf(double v)
<V2> V convert(V2 src, ValueAccessor<V2> accessor)
V allocate(int size)
ValueAccessor.ObjectFactory<V> factory()
ValueAccessor.ObjectFactory
for the backing type static <L,R> int compare(L left, ValueAccessor<L> leftAccessor, R right, ValueAccessor<R> rightAccessor)
static <L,R> boolean equals(L left, ValueAccessor<L> leftAccessor, R right, ValueAccessor<R> rightAccessor)
Copyright © 2009-2021 The Apache Software Foundation