Class SetType<T>

All Implemented Interfaces:
Comparator<ByteBuffer>, AssignmentTestable

public class SetType<T> extends CollectionType<Set<T>>
  • Constructor Details

    • SetType

      public SetType(AbstractType<T> elements, boolean isMultiCell)
  • Method Details

    • getInstance

      public static SetType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
      Throws:
      ConfigurationException
      SyntaxException
    • getInstance

      public static <T> SetType<T> getInstance(AbstractType<T> elements, boolean isMultiCell)
    • referencesUserType

      public <V> boolean referencesUserType(V name, ValueAccessor<V> accessor)
      Overrides:
      referencesUserType in class AbstractType<Set<T>>
    • withUpdatedUserType

      public SetType<?> withUpdatedUserType(UserType udt)
      Description copied from class: AbstractType
      Returns an instance of this type with all references to the provided user type recursively replaced with its new definition.
      Overrides:
      withUpdatedUserType in class AbstractType<Set<T>>
    • expandUserTypes

      public AbstractType<?> expandUserTypes()
      Description copied from class: AbstractType
      Replace any instances of UserType with equivalent TupleType-s. We need it for dropped_columns, to allow safely dropping unused user types later without retaining any references to them in system_schema.dropped_columns.
      Overrides:
      expandUserTypes in class AbstractType<Set<T>>
    • getElementsType

      public AbstractType<T> getElementsType()
    • nameComparator

      public AbstractType<T> nameComparator()
      Specified by:
      nameComparator in class CollectionType<Set<T>>
    • valueComparator

      public AbstractType<?> valueComparator()
      Specified by:
      valueComparator in class CollectionType<Set<T>>
    • isMultiCell

      public boolean isMultiCell()
      Overrides:
      isMultiCell in class AbstractType<Set<T>>
    • freeze

      public AbstractType<?> freeze()
      Overrides:
      freeze in class AbstractType<Set<T>>
    • unfreeze

      public AbstractType<?> unfreeze()
      Overrides:
      unfreeze in class AbstractType<Set<T>>
    • subTypes

      public List<AbstractType<?>> subTypes()
      Overrides:
      subTypes in class AbstractType<Set<T>>
    • freezeNestedMulticellTypes

      public AbstractType<?> freezeNestedMulticellTypes()
      Description copied from class: AbstractType
      Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections explicitly frozen. This is only necessary for 2.x -> 3.x schema migrations, and can be removed in Cassandra 4.0. See CASSANDRA-11609 and CASSANDRA-11613.
      Overrides:
      freezeNestedMulticellTypes in class AbstractType<Set<T>>
    • isCompatibleWithFrozen

      public boolean isCompatibleWithFrozen(CollectionType<?> previous)
      Description copied from class: CollectionType
      A version of isCompatibleWith() to deal with non-multicell (frozen) collections
      Specified by:
      isCompatibleWithFrozen in class CollectionType<Set<T>>
    • isValueCompatibleWithFrozen

      public boolean isValueCompatibleWithFrozen(CollectionType<?> previous)
      Description copied from class: CollectionType
      A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections
      Specified by:
      isValueCompatibleWithFrozen in class CollectionType<Set<T>>
    • 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<Set<T>>
    • asComparableBytes

      public <V> ByteSource asComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version version)
      Description copied from class: AbstractType
      Produce a byte-comparable representation of the given value, i.e. a sequence of bytes that compares the same way using lexicographical unsigned byte comparison as the original value using the type's comparator. We use a slightly stronger requirement to be able to use the types in tuples. Precisely, for any pair x, y of non-equal valid values of this type and any bytes b1, b2 between 0x10 and 0xEF, (+ stands for concatenation) compare(x, y) == compareLexicographicallyUnsigned(asByteComparable(x)+b1, asByteComparable(y)+b2) (i.e. the values compare like the original type, and an added 0x10-0xEF byte at the end does not change that) and: asByteComparable(x)+b1 is not a prefix of asByteComparable(y) (weakly prefix free) (i.e. a valid representation of a value may be a prefix of another valid representation of a value only if the following byte in the latter is smaller than 0x10 or larger than 0xEF). These properties are trivially true if the encoding compares correctly and is prefix free, but also permits a little more freedom that enables somewhat more efficient encoding of arbitrary-length byte-comparable blobs. Depending on the type, this method can be called for null or empty input, in which case the output is allowed to be null (the clustering/tuple encoding will accept and handle it).
      Overrides:
      asComparableBytes in class AbstractType<Set<T>>
    • fromComparableBytes

      public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
      Description copied from class: AbstractType
      Translates the given byte-ordered representation to the common, non-byte-ordered binary representation of a payload for this abstract type (the latter, common binary representation is what we mostly work with in the storage engine internals). If the given bytes don't correspond to the encoding of some payload value for this abstract type, an IllegalArgumentException may be thrown.
      Overrides:
      fromComparableBytes in class AbstractType<Set<T>>
      Parameters:
      accessor - value accessor used to construct the value.
      comparableBytes - A byte-ordered representation (presumably of a payload for this abstract type).
      version - The byte-comparable version used to construct the representation.
      Returns:
      A of a payload for this abstract type, corresponding to the given byte-ordered representation, constructed using the supplied value accessor.
      See Also:
    • getSerializer

      public SetSerializer<T> getSerializer()
      Specified by:
      getSerializer in class CollectionType<Set<T>>
    • toString

      public String toString(boolean ignoreFreezing)
      Overrides:
      toString in class AbstractType<Set<T>>
      Parameters:
      ignoreFreezing - if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.
    • serializedValues

      public List<ByteBuffer> serializedValues(Iterator<Cell<?>> cells)
      Specified by:
      serializedValues in class CollectionType<Set<T>>
    • fromJSONObject

      public Term fromJSONObject(Object parsed) throws MarshalException
      Description copied from class: AbstractType
      Given a parsed JSON string, return a byte representation of the object.
      Specified by:
      fromJSONObject in class AbstractType<Set<T>>
      Parameters:
      parsed - the result of parsing a json string
      Throws:
      MarshalException
    • 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<Set<T>>
      Parameters:
      buffer - the value to convert
      protocolVersion - the protocol version to use for the conversion
      Returns:
      a JSON string representing the specified value
    • forEach

      public void forEach(ByteBuffer input, Consumer<ByteBuffer> action)
      Specified by:
      forEach in class CollectionType<Set<T>>
    • getMaskedValue

      public ByteBuffer getMaskedValue()
      Overrides:
      getMaskedValue in class AbstractType<Set<T>>
      Returns:
      A fixed, serialized value to be used when the column is masked, to be returned instead of the real value.