Class AbstractCompositeType

java.lang.Object
org.apache.cassandra.db.marshal.AbstractType<ByteBuffer>
org.apache.cassandra.db.marshal.AbstractCompositeType
All Implemented Interfaces:
Comparator<ByteBuffer>, AssignmentTestable
Direct Known Subclasses:
CompositeType, DynamicCompositeType

public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
A class avoiding class duplication between CompositeType and DynamicCompositeType. Those two differs only in that for DynamicCompositeType, the comparators are in the encoded column name at the front of each component.
  • Constructor Details

    • AbstractCompositeType

      protected AbstractCompositeType()
  • Method Details

    • allowsEmpty

      public boolean allowsEmpty()
      Description copied from class: AbstractType
      Defines if the type allows an empty set of bytes (new byte[0]) as valid input. The AbstractType.validate(Object, ValueAccessor) and AbstractType.compose(Object, ValueAccessor) methods must allow empty bytes when this returns true, and must reject empty bytes when this is false.

      As of this writing, the main user of this API is for testing to know what types allow empty values and what types don't, so that the data that gets generated understands when ByteBufferUtil.EMPTY_BYTE_BUFFER is allowed as valid data.

      Overrides:
      allowsEmpty in class AbstractType<ByteBuffer>
    • compareCustom

      public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)
      Description copied from class: AbstractType
      Implement IFF ComparisonType is CUSTOM Compares the byte representation of two instances of this class, for types where this cannot be done by simple in-order comparison of the unsigned bytes Standard Java compare semantics
      Overrides:
      compareCustom in class AbstractType<ByteBuffer>
    • readIsStatic

      protected abstract <V> boolean readIsStatic(V value, ValueAccessor<V> accessor)
    • startingOffset

      protected abstract int startingOffset(boolean isStatic)
    • split

      public ByteBuffer[] split(ByteBuffer bb)
      Split a composite column names into it's components.
    • escape

      public static String escape(String input)
    • getString

      public <V> String getString(V input, ValueAccessor<V> accessor)
      Description copied from class: AbstractType
      get a string representation of the bytes used for various identifier (NOT just for log messages)
      Overrides:
      getString in class AbstractType<ByteBuffer>
    • fromString

      public ByteBuffer fromString(String source)
      Description copied from class: AbstractType
      get a byte representation of the given string.
      Specified by:
      fromString in class AbstractType<ByteBuffer>
    • fromJSONObject

      public Term fromJSONObject(Object parsed)
      Description copied from class: AbstractType
      Given a parsed JSON string, return a byte representation of the object.
      Specified by:
      fromJSONObject in class AbstractType<ByteBuffer>
      Parameters:
      parsed - the result of parsing a json string
    • toJSONString

      public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
      Description copied from class: AbstractType
      Converts the specified value into its JSON representation.

      The buffer position will stay the same.

      Overrides:
      toJSONString in class AbstractType<ByteBuffer>
      Parameters:
      buffer - the value to convert
      protocolVersion - the protocol version to use for the conversion
      Returns:
      a JSON string representing the specified value
    • validate

      public void validate(ByteBuffer bb) throws MarshalException
      Overrides:
      validate in class AbstractType<ByteBuffer>
      Throws:
      MarshalException
    • validate

      public <V> void validate(V input, ValueAccessor<V> accessor)
      Overrides:
      validate in class AbstractType<ByteBuffer>
    • decompose

      public abstract ByteBuffer decompose(Object... objects)
    • getComparatorSize

      protected abstract <V> int getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)
    • getComparator

      protected abstract <V> AbstractType<?> getComparator(int i, V value, ValueAccessor<V> accessor, int offset)
      Parameters:
      i - DynamicCompositeType will read the type information from @param bb
      value - name of type definition
      Returns:
      the comparator for the given component. static CompositeType will consult
    • getComparator

      protected abstract <VL, VR> AbstractType<?> getComparator(int i, VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR, int offsetL, int offsetR)
      Adds DynamicCompositeType type information from @param bb1 to @param bb2.
      Parameters:
      i - is ignored.
    • getAndAppendComparator

      protected abstract <V> AbstractType<?> getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, StringBuilder sb, int offset)
      Adds type information from @param bb to @param sb. @param i is ignored.
    • validateComparator

      protected abstract <V> AbstractType<?> validateComparator(int i, V value, ValueAccessor<V> accessor, int offset) throws MarshalException
      Like getComparator, but validates that @param i does not exceed the defined range
      Throws:
      MarshalException
    • parseComparator

      protected abstract AbstractCompositeType.ParsedComparator parseComparator(int i, String part)
      Used by fromString