Class CollectionSerializer<T>

    • Constructor Detail

      • CollectionSerializer

        public CollectionSerializer()
    • Method Detail

      • serializeValues

        protected abstract java.util.List<java.nio.ByteBuffer> serializeValues​(T value)
      • getElementCount

        protected abstract int getElementCount​(T value)
      • deserializeForNativeProtocol

        public abstract <V> T deserializeForNativeProtocol​(V value,
                                                           ValueAccessor<V> accessor,
                                                           ProtocolVersion version)
      • deserializeForNativeProtocol

        public T deserializeForNativeProtocol​(java.nio.ByteBuffer value,
                                              ProtocolVersion version)
      • validateForNativeProtocol

        public abstract <V> void validateForNativeProtocol​(V value,
                                                           ValueAccessor<V> accessor,
                                                           ProtocolVersion version)
      • pack

        public static java.nio.ByteBuffer pack​(java.util.Collection<java.nio.ByteBuffer> values,
                                               int elements,
                                               ProtocolVersion version)
      • writeCollectionSize

        protected static void writeCollectionSize​(java.nio.ByteBuffer output,
                                                  int elements,
                                                  ProtocolVersion version)
      • readCollectionSize

        public static int readCollectionSize​(java.nio.ByteBuffer input,
                                             ProtocolVersion version)
      • sizeOfCollectionSize

        public static int sizeOfCollectionSize​(int elements,
                                               ProtocolVersion version)
      • writeValue

        public static <V> void writeValue​(java.nio.ByteBuffer output,
                                          V value,
                                          ValueAccessor<V> accessor,
                                          ProtocolVersion version)
      • skipValue

        protected static void skipValue​(java.nio.ByteBuffer input,
                                        ProtocolVersion version)
      • getSerializedValue

        public abstract java.nio.ByteBuffer getSerializedValue​(java.nio.ByteBuffer collection,
                                                               java.nio.ByteBuffer key,
                                                               AbstractType<?> comparator)
        Extract 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 null otherwise.

        Parameters:
        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.
        Returns:
        the value associated with key if one exists, null otherwise
      • getSliceFromSerialized

        public 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.

        If the slice contains no elements an empty collection will be returned for frozen collections, and a null one for non-frozen collections.

        Parameters:
        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
        Returns:
        a serialized collection corresponding to slice [from, to] of collection.
      • copyAsNewCollection

        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.