public class SetSerializer<T> extends CollectionSerializer<java.util.Set<T>>
Modifier and Type | Field and Description |
---|---|
TypeSerializer<T> |
elements |
Constructor and Description |
---|
SetSerializer(TypeSerializer<T> elements,
ValueComparators comparators) |
Modifier and Type | Method and Description |
---|---|
<V> java.util.Set<T> |
deserializeForNativeProtocol(V input,
ValueAccessor<V> accessor,
ProtocolVersion version) |
int |
getElementCount(java.util.Set<T> value) |
static <T> SetSerializer<T> |
getInstance(TypeSerializer<T> elements,
ValueComparators comparators) |
java.nio.ByteBuffer |
getSerializedValue(java.nio.ByteBuffer input,
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.Set<T>> |
getType() |
java.util.List<java.nio.ByteBuffer> |
serializeValues(java.util.Set<T> values) |
java.lang.String |
toString(java.util.Set<T> value) |
<V> void |
validateForNativeProtocol(V input,
ValueAccessor<V> 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<T> elements
public SetSerializer(TypeSerializer<T> elements, ValueComparators comparators)
public static <T> SetSerializer<T> getInstance(TypeSerializer<T> elements, ValueComparators comparators)
public java.util.List<java.nio.ByteBuffer> serializeValues(java.util.Set<T> values)
serializeValues
in class CollectionSerializer<java.util.Set<T>>
public int getElementCount(java.util.Set<T> value)
getElementCount
in class CollectionSerializer<java.util.Set<T>>
public <V> void validateForNativeProtocol(V input, ValueAccessor<V> accessor, ProtocolVersion version)
validateForNativeProtocol
in class CollectionSerializer<java.util.Set<T>>
public <V> java.util.Set<T> deserializeForNativeProtocol(V input, ValueAccessor<V> accessor, ProtocolVersion version)
deserializeForNativeProtocol
in class CollectionSerializer<java.util.Set<T>>
public java.lang.String toString(java.util.Set<T> value)
toString
in class TypeSerializer<java.util.Set<T>>
public java.lang.Class<java.util.Set<T>> getType()
getType
in class TypeSerializer<java.util.Set<T>>
public java.nio.ByteBuffer getSerializedValue(java.nio.ByteBuffer input, 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.Set<T>>
input
- 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.Set<T>>
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
.Copyright © 2009-2021 The Apache Software Foundation