Class CodecUtils

java.lang.Object
org.apache.cassandra.cql3.functions.types.CodecUtils

public final class CodecUtils extends Object
A set of utility methods to deal with type conversion and serialization.
  • Method Details

    • pack

      public static ByteBuffer pack(ByteBuffer[] buffers, int elements, ProtocolVersion version)
      Utility method that "packs" together a list of ByteBuffers containing serialized collection elements. Mainly intended for use with collection codecs when serializing collections.
      Parameters:
      buffers - the collection elements
      elements - the total number of elements
      version - the protocol version to use
      Returns:
      The serialized collection
    • readValue

      public static ByteBuffer readValue(ByteBuffer input, ProtocolVersion version)
      Utility method that reads a value. Mainly intended for collection codecs when deserializing CQL collections.
      Parameters:
      input - The ByteBuffer to read from.
      version - The protocol version to use.
      Returns:
      The collection element.
    • writeValue

      public static void writeValue(ByteBuffer output, ByteBuffer value, ProtocolVersion version)
      Utility method that writes a value. Mainly intended for collection codecs when deserializing CQL collections.
      Parameters:
      output - The ByteBuffer to write to.
      value - The value to write.
      version - The protocol version to use.
    • readBytes

      public static ByteBuffer readBytes(ByteBuffer bb, int length)
      Read length bytes from bb into a new ByteBuffer.
      Parameters:
      bb - The ByteBuffer to read.
      length - The number of bytes to read.
      Returns:
      The read bytes.