public abstract class CollectionSerializer<T> extends 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. |
<V> T |
deserialize(V value,
ValueAccessor<V> accessor) |
T |
deserializeForNativeProtocol(java.nio.ByteBuffer value,
ProtocolVersion version) |
abstract <V> T |
deserializeForNativeProtocol(V value,
ValueAccessor<V> accessor,
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> values,
int elements,
ProtocolVersion version) |
static <V> V |
pack(java.util.Collection<V> values,
ValueAccessor<V> accessor,
int elements,
ProtocolVersion version) |
static int |
readCollectionSize(java.nio.ByteBuffer input,
ProtocolVersion version) |
static <V> int |
readCollectionSize(V value,
ValueAccessor<V> accessor,
ProtocolVersion version) |
static <V> V |
readValue(V input,
ValueAccessor<V> accessor,
int offset,
ProtocolVersion version) |
java.nio.ByteBuffer |
serialize(T input) |
protected abstract java.util.List<java.nio.ByteBuffer> |
serializeValues(T value) |
static int |
sizeOfCollectionSize(int elements,
ProtocolVersion version) |
static <V> int |
sizeOfValue(V value,
ValueAccessor<V> accessor,
ProtocolVersion version) |
protected static void |
skipValue(java.nio.ByteBuffer input,
ProtocolVersion version) |
static <V> int |
skipValue(V input,
ValueAccessor<V> accessor,
int offset,
ProtocolVersion version) |
<T1> void |
validate(T1 value,
ValueAccessor<T1> accessor) |
abstract <V> void |
validateForNativeProtocol(V value,
ValueAccessor<V> accessor,
ProtocolVersion version) |
protected static void |
writeCollectionSize(java.nio.ByteBuffer output,
int elements,
ProtocolVersion version) |
static <V> void |
writeValue(java.nio.ByteBuffer output,
V value,
ValueAccessor<V> accessor,
ProtocolVersion version) |
deserialize, getType, toCQLLiteral, toString, validateprotected abstract java.util.List<java.nio.ByteBuffer> serializeValues(T value)
protected abstract int getElementCount(T value)
public abstract <V> T deserializeForNativeProtocol(V value, ValueAccessor<V> accessor, ProtocolVersion version)
public T deserializeForNativeProtocol(java.nio.ByteBuffer value, ProtocolVersion version)
public abstract <V> void validateForNativeProtocol(V value,
ValueAccessor<V> accessor,
ProtocolVersion version)
public java.nio.ByteBuffer serialize(T input)
serialize in class TypeSerializer<T>public <V> T deserialize(V value, ValueAccessor<V> accessor)
deserialize in class TypeSerializer<T>public <T1> void validate(T1 value,
ValueAccessor<T1> accessor)
throws MarshalException
validate in class TypeSerializer<T>MarshalExceptionpublic static java.nio.ByteBuffer pack(java.util.Collection<java.nio.ByteBuffer> values,
int elements,
ProtocolVersion version)
public static <V> V pack(java.util.Collection<V> values,
ValueAccessor<V> accessor,
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)
public static <V> int readCollectionSize(V value,
ValueAccessor<V> accessor,
ProtocolVersion version)
public static int sizeOfCollectionSize(int elements,
ProtocolVersion version)
public static <V> void writeValue(java.nio.ByteBuffer output,
V value,
ValueAccessor<V> accessor,
ProtocolVersion version)
public static <V> V readValue(V input,
ValueAccessor<V> accessor,
int offset,
ProtocolVersion version)
protected static void skipValue(java.nio.ByteBuffer input,
ProtocolVersion version)
public static <V> int skipValue(V input,
ValueAccessor<V> accessor,
int offset,
ProtocolVersion version)
public static <V> int sizeOfValue(V value,
ValueAccessor<V> accessor,
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