Class TypeCodec.PrimitiveIntCodec

java.lang.Object
org.apache.cassandra.cql3.functions.types.TypeCodec<Integer>
org.apache.cassandra.cql3.functions.types.TypeCodec.PrimitiveIntCodec
Enclosing class:
TypeCodec<T>

public abstract static class TypeCodec.PrimitiveIntCodec extends TypeCodec<Integer>
A codec that is capable of handling primitive ints, thus avoiding the overhead of boxing and unboxing such primitives.
  • Method Details

    • serializeNoBoxing

      public abstract ByteBuffer serializeNoBoxing(int v, ProtocolVersion protocolVersion)
    • deserializeNoBoxing

      public abstract int deserializeNoBoxing(ByteBuffer v, ProtocolVersion protocolVersion)
    • serialize

      public ByteBuffer serialize(Integer value, ProtocolVersion protocolVersion)
      Description copied from class: TypeCodec
      Serialize the given value according to the CQL type handled by this codec.

      Implementation notes:

      1. Null values should be gracefully handled and no exception should be raised; these should be considered as the equivalent of a NULL CQL value;
      2. Codecs for CQL collection types should not permit null elements;
      3. Codecs for CQL collection types should treat a null input as the equivalent of an empty collection.
      Specified by:
      serialize in class TypeCodec<Integer>
      Parameters:
      value - An instance of T; may be null.
      protocolVersion - the protocol version to use when serializing bytes. In most cases, the proper value to provide for this argument is the value returned by ProtocolOptions#getProtocolVersion (which is the protocol version in use by the driver).
      Returns:
      A ByteBuffer instance containing the serialized form of T
    • deserialize

      public Integer deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
      Description copied from class: TypeCodec
      Deserialize the given ByteBuffer instance according to the CQL type handled by this codec.

      Implementation notes:

      1. Null or empty buffers should be gracefully handled and no exception should be raised; these should be considered as the equivalent of a NULL CQL value and, in most cases, should map to null or a default value for the corresponding Java type, if applicable;
      2. Codecs for CQL collection types should clearly document whether they return immutable collections or not (note that the driver's default collection codecs return mutable collections);
      3. Codecs for CQL collection types should avoid returning null; they should return empty collections instead (the driver's default collection codecs all comply with this rule).
      4. The provided ByteBuffer should never be consumed by read operations that modify its current position; if necessary, ByteBuffer.duplicate() duplicate} it before consuming.
      Specified by:
      deserialize in class TypeCodec<Integer>
      Parameters:
      bytes - A ByteBuffer instance containing the serialized form of T; may be null or empty.
      protocolVersion - the protocol version to use when serializing bytes. In most cases, the proper value to provide for this argument is the value returned by ProtocolOptions#getProtocolVersion (which is the protocol version in use by the driver).
      Returns:
      An instance of T