Package org.apache.cassandra.serializers
Class MapSerializer<K,V>
- java.lang.Object
-
- org.apache.cassandra.serializers.TypeSerializer<T>
-
- org.apache.cassandra.serializers.CollectionSerializer<java.util.Map<K,V>>
-
- org.apache.cassandra.serializers.MapSerializer<K,V>
-
public class MapSerializer<K,V> extends CollectionSerializer<java.util.Map<K,V>>
-
-
Field Summary
Fields Modifier and Type Field Description TypeSerializer<K>keysTypeSerializer<V>values
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <I> java.util.Map<K,V>deserializeForNativeProtocol(I input, ValueAccessor<I> accessor, ProtocolVersion version)intgetElementCount(java.util.Map<K,V> value)static <K,V>
MapSerializer<K,V>getInstance(TypeSerializer<K> keys, TypeSerializer<V> values, ValueComparators comparators)java.nio.ByteBuffergetSerializedValue(java.nio.ByteBuffer collection, java.nio.ByteBuffer key, AbstractType<?> comparator)Extract an element from a serialized collection.java.nio.ByteBuffergetSliceFromSerialized(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.StringtoString(java.util.Map<K,V> value)<T> voidvalidateForNativeProtocol(T input, ValueAccessor<T> accessor, ProtocolVersion version)-
Methods inherited from class org.apache.cassandra.serializers.CollectionSerializer
copyAsNewCollection, deserialize, deserializeForNativeProtocol, pack, pack, readCollectionSize, readCollectionSize, readNonNullValue, readValue, serialize, sizeOfCollectionSize, sizeOfValue, skipValue, skipValue, validate, writeCollectionSize, writeValue
-
Methods inherited from class org.apache.cassandra.serializers.TypeSerializer
deserialize, toCQLLiteral, validate
-
-
-
-
Field Detail
-
keys
public final TypeSerializer<K> keys
-
values
public final TypeSerializer<V> values
-
-
Method Detail
-
getInstance
public static <K,V> MapSerializer<K,V> getInstance(TypeSerializer<K> keys, TypeSerializer<V> values, ValueComparators comparators)
-
serializeValues
public java.util.List<java.nio.ByteBuffer> serializeValues(java.util.Map<K,V> map)
- Specified by:
serializeValuesin classCollectionSerializer<java.util.Map<K,V>>
-
getElementCount
public int getElementCount(java.util.Map<K,V> value)
- Specified by:
getElementCountin classCollectionSerializer<java.util.Map<K,V>>
-
validateForNativeProtocol
public <T> void validateForNativeProtocol(T input, ValueAccessor<T> accessor, ProtocolVersion version)- Specified by:
validateForNativeProtocolin classCollectionSerializer<java.util.Map<K,V>>
-
deserializeForNativeProtocol
public <I> java.util.Map<K,V> deserializeForNativeProtocol(I input, ValueAccessor<I> accessor, ProtocolVersion version)
- Specified by:
deserializeForNativeProtocolin classCollectionSerializer<java.util.Map<K,V>>
-
getSerializedValue
public java.nio.ByteBuffer getSerializedValue(java.nio.ByteBuffer collection, java.nio.ByteBuffer key, AbstractType<?> comparator)Description copied from class:CollectionSerializerExtract an element from a serialized collection.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
nullotherwise.- Specified by:
getSerializedValuein classCollectionSerializer<java.util.Map<K,V>>- Parameters:
collection- the serialized collection. This cannot benull.key- the key to extract (This cannot benullnorByteBufferUtil.UNSET_BYTE_BUFFER).comparator- the type to use to compare thekeyvalue to those in the collection.- Returns:
- the value associated with
keyif one exists,nullotherwise
-
getSliceFromSerialized
public java.nio.ByteBuffer getSliceFromSerialized(java.nio.ByteBuffer collection, java.nio.ByteBuffer from, java.nio.ByteBuffer to, AbstractType<?> comparator, boolean frozen)Description copied from class:CollectionSerializerReturns the slice of a collection directly from its serialized value.If the slice contains no elements an empty collection will be returned for frozen collections, and a
nullone for non-frozen collections.- Specified by:
getSliceFromSerializedin classCollectionSerializer<java.util.Map<K,V>>- Parameters:
collection- the serialized collection. This cannot benull.from- the left bound of the slice to extract. This cannot benullbut if this isByteBufferUtil.UNSET_BYTE_BUFFER, then the returned slice starts at the beginning ofcollection.comparator- the type to use to compare thefromandtovalues to those in the collection.frozen-trueif the collection is a frozen one,falseotherwise- Returns:
- a serialized collection corresponding to slice
[from, to]ofcollection.
-
toString
public java.lang.String toString(java.util.Map<K,V> value)
- Specified by:
toStringin classTypeSerializer<java.util.Map<K,V>>
-
-