public abstract class CollectionSerializer<T> extends java.lang.Object implements TypeSerializer<T>
Constructor and Description |
---|
CollectionSerializer() |
Modifier and Type | Method and Description |
---|---|
protected java.nio.ByteBuffer |
copyAsNewCollection(java.nio.ByteBuffer input,
int count,
int startPos,
int endPos,
ProtocolVersion version)
Creates a new serialized map composed from the data from
input between startPos
(inclusive) and endPos (exclusive), assuming that data holds count elements. |
T |
deserialize(java.nio.ByteBuffer bytes) |
abstract T |
deserializeForNativeProtocol(java.nio.ByteBuffer buffer,
ProtocolVersion version) |
protected abstract int |
getElementCount(T value) |
abstract java.nio.ByteBuffer |
getSerializedValue(java.nio.ByteBuffer collection,
java.nio.ByteBuffer key,
AbstractType<?> comparator)
Extract an element from a serialized collection.
|
abstract java.nio.ByteBuffer |
getSliceFromSerialized(java.nio.ByteBuffer collection,
java.nio.ByteBuffer from,
java.nio.ByteBuffer to,
AbstractType<?> comparator,
boolean frozen)
Returns the slice of a collection directly from its serialized value.
|
static java.nio.ByteBuffer |
pack(java.util.Collection<java.nio.ByteBuffer> buffers,
int elements,
ProtocolVersion version) |
static int |
readCollectionSize(java.nio.ByteBuffer input,
ProtocolVersion version) |
static java.nio.ByteBuffer |
readValue(java.nio.ByteBuffer input,
ProtocolVersion version) |
java.nio.ByteBuffer |
serialize(T value) |
protected abstract java.util.List<java.nio.ByteBuffer> |
serializeValues(T value) |
protected static int |
sizeOfCollectionSize(int elements,
ProtocolVersion version) |
static int |
sizeOfValue(java.nio.ByteBuffer value,
ProtocolVersion version) |
protected static void |
skipValue(java.nio.ByteBuffer input,
ProtocolVersion version) |
void |
validate(java.nio.ByteBuffer bytes) |
abstract void |
validateForNativeProtocol(java.nio.ByteBuffer buffer,
ProtocolVersion version) |
protected static void |
writeCollectionSize(java.nio.ByteBuffer output,
int elements,
ProtocolVersion version) |
static void |
writeValue(java.nio.ByteBuffer output,
java.nio.ByteBuffer value,
ProtocolVersion version) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getType, toCQLLiteral, toString
protected abstract java.util.List<java.nio.ByteBuffer> serializeValues(T value)
protected abstract int getElementCount(T value)
public abstract T deserializeForNativeProtocol(java.nio.ByteBuffer buffer, ProtocolVersion version)
public abstract void validateForNativeProtocol(java.nio.ByteBuffer buffer, ProtocolVersion version)
public java.nio.ByteBuffer serialize(T value)
serialize
in interface TypeSerializer<T>
public T deserialize(java.nio.ByteBuffer bytes)
deserialize
in interface TypeSerializer<T>
public void validate(java.nio.ByteBuffer bytes) throws MarshalException
validate
in interface TypeSerializer<T>
MarshalException
public static java.nio.ByteBuffer pack(java.util.Collection<java.nio.ByteBuffer> buffers, int elements, ProtocolVersion version)
protected static void writeCollectionSize(java.nio.ByteBuffer output, int elements, ProtocolVersion version)
public static int readCollectionSize(java.nio.ByteBuffer input, ProtocolVersion version)
protected static int sizeOfCollectionSize(int elements, ProtocolVersion version)
public static void writeValue(java.nio.ByteBuffer output, java.nio.ByteBuffer value, ProtocolVersion version)
public static java.nio.ByteBuffer readValue(java.nio.ByteBuffer input, ProtocolVersion version)
protected static void skipValue(java.nio.ByteBuffer input, ProtocolVersion version)
public static int sizeOfValue(java.nio.ByteBuffer value, ProtocolVersion version)
public abstract java.nio.ByteBuffer getSerializedValue(java.nio.ByteBuffer collection, java.nio.ByteBuffer key, AbstractType<?> comparator)
Note that this is only supported to sets and maps. For sets, this mostly ends up being
a check for the presence of the provide key: it will return the key if it's present and
null
otherwise.
collection
- the serialized collection. This cannot be null
.key
- the key to extract (This cannot be null
nor ByteBufferUtil.UNSET_BYTE_BUFFER
).comparator
- the type to use to compare the key
value to those
in the collection.key
if one exists, null
otherwisepublic abstract java.nio.ByteBuffer getSliceFromSerialized(java.nio.ByteBuffer collection, java.nio.ByteBuffer from, java.nio.ByteBuffer to, AbstractType<?> comparator, boolean frozen)
If the slice contains no elements an empty collection will be returned for frozen collections, and a
null
one for non-frozen collections.
collection
- the serialized collection. This cannot be null
.from
- the left bound of the slice to extract. This cannot be null
but if this is
ByteBufferUtil.UNSET_BYTE_BUFFER
, then the returned slice starts at the beginning
of collection
.comparator
- the type to use to compare the from
and to
values to those
in the collection.frozen
- true
if the collection is a frozen one, false
otherwise[from, to]
of collection
.protected java.nio.ByteBuffer copyAsNewCollection(java.nio.ByteBuffer input, int count, int startPos, int endPos, ProtocolVersion version)
input
between startPos
(inclusive) and endPos
(exclusive), assuming that data holds count
elements.Copyright © 2009-2020 The Apache Software Foundation