Package org.apache.cassandra.db.marshal
Class CompositeType
- java.lang.Object
-
- org.apache.cassandra.db.marshal.AbstractType<java.nio.ByteBuffer>
-
- org.apache.cassandra.db.marshal.AbstractCompositeType
-
- org.apache.cassandra.db.marshal.CompositeType
-
- All Implemented Interfaces:
java.util.Comparator<java.nio.ByteBuffer>,AssignmentTestable
public class CompositeType extends AbstractCompositeType
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractCompositeType
AbstractCompositeType.ParsedComparator
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType
AbstractType.ComparisonType
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<AbstractType<?>>types-
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCompositeType(java.util.List<AbstractType<?>> types)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> Vbuild(ValueAccessor<V> accessor, boolean isStatic, V... values)static <V> Vbuild(ValueAccessor<V> accessor, V... values)java.nio.ByteBufferdecompose(java.lang.Object... objects)AbstractType<?>expandUserTypes()Replace any instances of UserType with equivalent TupleType-s.static java.nio.ByteBufferextractComponent(java.nio.ByteBuffer bb, int idx)protected <V> AbstractType<?>getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, java.lang.StringBuilder sb, int offset)Adds type information from @param bb to @param sb.protected <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.protected <V> AbstractType<?>getComparator(int i, V value, ValueAccessor<V> accessor, int offset)protected <V> intgetComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)java.util.List<AbstractType<?>>getComponents()Return a list of the "subcomponents" this type has.static CompositeTypegetInstance(java.lang.Iterable<AbstractType<?>> types)static CompositeTypegetInstance(java.util.List<AbstractType<?>> types)static CompositeTypegetInstance(AbstractType... types)static CompositeTypegetInstance(TypeParser parser)TypeSerializer<java.nio.ByteBuffer>getSerializer()booleanisCompatibleWith(AbstractType<?> previous)Returns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this.static <V> booleanisStaticName(V value, ValueAccessor<V> accessor)booleanisValueCompatibleWithInternal(AbstractType<?> otherType)Needed to handle ReversedType in value-compatibility checks.protected AbstractCompositeType.ParsedComparatorparseComparator(int i, java.lang.String part)Used by fromStringprotected <V> booleanreadIsStatic(V value, ValueAccessor<V> accessor)protected static <V> booleanreadIsStaticInternal(V value, ValueAccessor<V> accessor)<V> booleanreferencesUserType(V name, ValueAccessor<V> accessor)java.nio.ByteBuffer[]split(java.nio.ByteBuffer name)Split a composite column names into it's components.static <V> java.util.List<V>splitName(V name, ValueAccessor<V> accessor)protected intstartingOffset(boolean isStatic)protected static intstartingOffsetInternal(boolean isStatic)java.lang.StringtoString()This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).protected <V> AbstractType<?>validateComparator(int i, V value, ValueAccessor<V> accessor, int offset)Like getComparator, but validates that @param i does not exceed the defined rangeCompositeTypewithUpdatedUserType(UserType udt)Returns an instance of this type with all references to the provided user type recursively replaced with its new definition.-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractCompositeType
compareCustom, escape, fromJSONObject, fromString, getString, toJSONString, validate, validate
-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, decomposeUntyped, freeze, freezeNestedMulticellTypes, getString, getString, isCollection, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toString, udfType, unwrap, validateCellValue, validateCollectionMember, valueLengthIfFixed, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Field Detail
-
types
public final java.util.List<AbstractType<?>> types
-
-
Constructor Detail
-
CompositeType
protected CompositeType(java.util.List<AbstractType<?>> types)
-
-
Method Detail
-
getInstance
public static CompositeType getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
-
getInstance
public static CompositeType getInstance(java.lang.Iterable<AbstractType<?>> types)
-
getInstance
public static CompositeType getInstance(AbstractType... types)
-
startingOffsetInternal
protected static int startingOffsetInternal(boolean isStatic)
-
startingOffset
protected int startingOffset(boolean isStatic)
- Specified by:
startingOffsetin classAbstractCompositeType
-
readIsStaticInternal
protected static <V> boolean readIsStaticInternal(V value, ValueAccessor<V> accessor)
-
readIsStatic
protected <V> boolean readIsStatic(V value, ValueAccessor<V> accessor)- Specified by:
readIsStaticin classAbstractCompositeType
-
getInstance
public static CompositeType getInstance(java.util.List<AbstractType<?>> types)
-
getSerializer
public TypeSerializer<java.nio.ByteBuffer> getSerializer()
- Overrides:
getSerializerin classAbstractCompositeType
-
getComparator
protected <V> AbstractType<?> getComparator(int i, V value, ValueAccessor<V> accessor, int offset)
- Specified by:
getComparatorin classAbstractCompositeType- Parameters:
i- DynamicCompositeType will read the type information from @param bbvalue- name of type definition- Returns:
- the comparator for the given component. static CompositeType will consult
-
getComparator
protected <VL,VR> AbstractType<?> getComparator(int i, VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR, int offsetL, int offsetR)
Description copied from class:AbstractCompositeTypeAdds DynamicCompositeType type information from @param bb1 to @param bb2.- Specified by:
getComparatorin classAbstractCompositeType- Parameters:
i- is ignored.
-
getAndAppendComparator
protected <V> AbstractType<?> getAndAppendComparator(int i, V value, ValueAccessor<V> accessor, java.lang.StringBuilder sb, int offset)
Description copied from class:AbstractCompositeTypeAdds type information from @param bb to @param sb. @param i is ignored.- Specified by:
getAndAppendComparatorin classAbstractCompositeType
-
parseComparator
protected AbstractCompositeType.ParsedComparator parseComparator(int i, java.lang.String part)
Description copied from class:AbstractCompositeTypeUsed by fromString- Specified by:
parseComparatorin classAbstractCompositeType
-
validateComparator
protected <V> AbstractType<?> validateComparator(int i, V value, ValueAccessor<V> accessor, int offset) throws MarshalException
Description copied from class:AbstractCompositeTypeLike getComparator, but validates that @param i does not exceed the defined range- Specified by:
validateComparatorin classAbstractCompositeType- Throws:
MarshalException
-
getComparatorSize
protected <V> int getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)- Specified by:
getComparatorSizein classAbstractCompositeType
-
decompose
public java.nio.ByteBuffer decompose(java.lang.Object... objects)
- Specified by:
decomposein classAbstractCompositeType
-
split
public java.nio.ByteBuffer[] split(java.nio.ByteBuffer name)
Description copied from class:AbstractCompositeTypeSplit a composite column names into it's components.- Overrides:
splitin classAbstractCompositeType
-
splitName
public static <V> java.util.List<V> splitName(V name, ValueAccessor<V> accessor)
-
extractComponent
public static java.nio.ByteBuffer extractComponent(java.nio.ByteBuffer bb, int idx)
-
isStaticName
public static <V> boolean isStaticName(V value, ValueAccessor<V> accessor)
-
getComponents
public java.util.List<AbstractType<?>> getComponents()
Description copied from class:AbstractTypeReturn a list of the "subcomponents" this type has. This always return a singleton list with the type itself except for CompositeType.- Overrides:
getComponentsin classAbstractType<java.nio.ByteBuffer>
-
isCompatibleWith
public boolean isCompatibleWith(AbstractType<?> previous)
Description copied from class:AbstractTypeReturns true if this comparator is compatible with the provided previous comparator, that is if previous can safely be replaced by this. A comparator cn should be compatible with a previous one cp if forall columns c1 and c2, if cn.validate(c1) and cn.validate(c2) and cn.compare(c1, c2) == v, then cp.validate(c1) and cp.validate(c2) and cp.compare(c1, c2) == v. Note that a type should be compatible with at least itself and when in doubt, keep the default behavior of not being compatible with any other comparator!- Overrides:
isCompatibleWithin classAbstractType<java.nio.ByteBuffer>
-
isValueCompatibleWithInternal
public boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
Description copied from class:AbstractTypeNeeded to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternalin classAbstractType<java.nio.ByteBuffer>
-
referencesUserType
public <V> boolean referencesUserType(V name, ValueAccessor<V> accessor)- Overrides:
referencesUserTypein classAbstractType<java.nio.ByteBuffer>
-
withUpdatedUserType
public CompositeType withUpdatedUserType(UserType udt)
Description copied from class:AbstractTypeReturns an instance of this type with all references to the provided user type recursively replaced with its new definition.- Overrides:
withUpdatedUserTypein classAbstractType<java.nio.ByteBuffer>
-
expandUserTypes
public AbstractType<?> expandUserTypes()
Description copied from class:AbstractTypeReplace 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:
expandUserTypesin classAbstractType<java.nio.ByteBuffer>
-
toString
public java.lang.String toString()
Description copied from class:AbstractTypeThis must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()). Note that for backwards compatibility this includes the full classname. For CQL purposes the short name is fine.- Overrides:
toStringin classAbstractType<java.nio.ByteBuffer>
-
build
@SafeVarargs public static <V> V build(ValueAccessor<V> accessor, V... values)
-
build
@SafeVarargs public static <V> V build(ValueAccessor<V> accessor, boolean isStatic, V... values)
-
-