public class MapSerializer<K,V> extends CollectionSerializer<java.util.Map<K,V>>
Modifier and Type | Field and Description |
---|---|
TypeSerializer<K> |
keys |
TypeSerializer<V> |
values |
Modifier and Type | Method and Description |
---|---|
<I> java.util.Map<K,V> |
deserializeForNativeProtocol(I input,
ValueAccessor<I> accessor,
ProtocolVersion version) |
int |
getElementCount(java.util.Map<K,V> value) |
static <K,V> MapSerializer<K,V> |
getInstance(TypeSerializer<K> keys,
TypeSerializer<V> values,
ValueComparators comparators) |
java.nio.ByteBuffer |
getSerializedValue(java.nio.ByteBuffer collection,
java.nio.ByteBuffer key,
AbstractType<?> comparator)
Extract an element from a serialized collection.
|
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.
|
java.lang.Class<java.util.Map<K,V>> |
getType() |
java.util.List<java.nio.ByteBuffer> |
serializeValues(java.util.Map<K,V> map) |
java.lang.String |
toString(java.util.Map<K,V> value) |
<T> void |
validateForNativeProtocol(T input,
ValueAccessor<T> accessor,
ProtocolVersion version) |
copyAsNewCollection, deserialize, deserializeForNativeProtocol, pack, pack, readCollectionSize, readCollectionSize, readValue, serialize, sizeOfCollectionSize, sizeOfValue, skipValue, skipValue, validate, writeCollectionSize, writeValue
deserialize, toCQLLiteral, validate
public final TypeSerializer<K> keys
public final TypeSerializer<V> values
public static <K,V> MapSerializer<K,V> getInstance(TypeSerializer<K> keys, TypeSerializer<V> values, ValueComparators comparators)
public java.util.List<java.nio.ByteBuffer> serializeValues(java.util.Map<K,V> map)
serializeValues
in class CollectionSerializer<java.util.Map<K,V>>
public int getElementCount(java.util.Map<K,V> value)
getElementCount
in class CollectionSerializer<java.util.Map<K,V>>
public <T> void validateForNativeProtocol(T input, ValueAccessor<T> accessor, ProtocolVersion version)
validateForNativeProtocol
in class CollectionSerializer<java.util.Map<K,V>>
public <I> java.util.Map<K,V> deserializeForNativeProtocol(I input, ValueAccessor<I> accessor, ProtocolVersion version)
deserializeForNativeProtocol
in class CollectionSerializer<java.util.Map<K,V>>
public java.nio.ByteBuffer getSerializedValue(java.nio.ByteBuffer collection, java.nio.ByteBuffer key, AbstractType<?> comparator)
CollectionSerializer
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.
getSerializedValue
in class CollectionSerializer<java.util.Map<K,V>>
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 java.nio.ByteBuffer getSliceFromSerialized(java.nio.ByteBuffer collection, java.nio.ByteBuffer from, java.nio.ByteBuffer to, AbstractType<?> comparator, boolean frozen)
CollectionSerializer
If the slice contains no elements an empty collection will be returned for frozen collections, and a
null
one for non-frozen collections.
getSliceFromSerialized
in class CollectionSerializer<java.util.Map<K,V>>
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
.public java.lang.String toString(java.util.Map<K,V> value)
toString
in class TypeSerializer<java.util.Map<K,V>>
Copyright © 2009-2021 The Apache Software Foundation