Package org.apache.cassandra.serializers
Class ListSerializer<T>
java.lang.Object
org.apache.cassandra.serializers.TypeSerializer<T>
org.apache.cassandra.serializers.CollectionSerializer<List<T>>
org.apache.cassandra.serializers.ListSerializer<T>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleananyMatch(ByteBuffer serializedList, Predicate<ByteBuffer> predicate) <V> booleananyMatch(V input, ValueAccessor<V> accessor, Predicate<V> predicate) deserialize(V input, ValueAccessor<V> accessor) getElement(ByteBuffer input, int index) <V> VgetElement(V input, ValueAccessor<V> accessor, int index) Returns the element at the given index in a list.intgetElementCount(List<T> value) com.google.common.collect.Range<Integer>getIndexesRangeFromSerialized(ByteBuffer collection, ByteBuffer from, ByteBuffer to, AbstractType<?> comparator) Returns the range of indexes corresponding to the specified range of elements in the serialized collection.intgetIndexFromSerialized(ByteBuffer collection, ByteBuffer key, AbstractType<?> comparator) Returns the index of an element in a serialized collection.static <T> ListSerializer<T>getInstance(TypeSerializer<T> elements) getSerializedValue(ByteBuffer collection, ByteBuffer key, AbstractType<?> comparator) Extract an element from a serialized collection.getSliceFromSerialized(ByteBuffer collection, ByteBuffer from, ByteBuffer to, AbstractType<?> comparator, boolean frozen) Returns the slice of a collection directly from its serialized value.getType()protected List<ByteBuffer>serializeValues(List<T> values) <V> voidvalidate(V input, ValueAccessor<V> accessor) Methods inherited from class org.apache.cassandra.serializers.CollectionSerializer
copyAsNewCollection, forEach, pack, pack, readCollectionSize, readNonNullValue, readValue, serialize, sizeOfCollectionSize, sizeOfValue, skipValue, skipValue, writeCollectionSize, writeValueMethods inherited from class org.apache.cassandra.serializers.TypeSerializer
deserialize, isNull, isNull, shouldQuoteCQLLiterals, toCQLLiteral, toCQLLiteralNonNull, toCQLLiteralNoQuote, validate
-
Field Details
-
elements
-
-
Method Details
-
getInstance
-
serializeValues
- Specified by:
serializeValuesin classCollectionSerializer<List<T>>
-
getElementCount
- Specified by:
getElementCountin classCollectionSerializer<List<T>>
-
validate
- Specified by:
validatein classTypeSerializer<List<T>>
-
deserialize
- Specified by:
deserializein classTypeSerializer<List<T>>
-
anyMatch
-
anyMatch
-
getElement
Returns the element at the given index in a list.- Parameters:
input- a serialized listindex- the index to get- Returns:
- the serialized element at the given index, or null if the index exceeds the list size
-
getElement
-
toString
- Specified by:
toStringin classTypeSerializer<List<T>>
-
getType
- Specified by:
getTypein classTypeSerializer<List<T>>
-
getSerializedValue
public ByteBuffer getSerializedValue(ByteBuffer collection, 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<List<T>>- 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 ByteBuffer getSliceFromSerialized(ByteBuffer collection, ByteBuffer from, 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<List<T>>- 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.
-
getIndexFromSerialized
public int getIndexFromSerialized(ByteBuffer collection, ByteBuffer key, AbstractType<?> comparator) Description copied from class:CollectionSerializerReturns the index of an element in a serialized collection.Note that this is only supported by sets and maps, but not by lists.
- Specified by:
getIndexFromSerializedin classCollectionSerializer<List<T>>- Parameters:
collection- The serialized collection. This cannot benull.key- The key for which the index must be found. This cannot benullnorByteBufferUtil.UNSET_BYTE_BUFFER).comparator- The type to use to compare thekeyvalue to those in the collection.- Returns:
- The index of the element associated with
keyif one exists,-1otherwise.
-
getIndexesRangeFromSerialized
public com.google.common.collect.Range<Integer> getIndexesRangeFromSerialized(ByteBuffer collection, ByteBuffer from, ByteBuffer to, AbstractType<?> comparator) Description copied from class:CollectionSerializerReturns the range of indexes corresponding to the specified range of elements in the serialized collection.Note that this is only supported by sets and maps, but not by lists.
- Specified by:
getIndexesRangeFromSerializedin classCollectionSerializer<List<T>>- 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 of the collection.to- The left bound of the slice to extract. This cannot benullbut if this isByteBufferUtil.UNSET_BYTE_BUFFER, then the returned slice ends at the end of the collection.comparator- The type to use to compare thefromandtovalues to those in the collection.- Returns:
- The range of indexes corresponding to specified range of elements.
-