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 protected
CompositeType(java.util.List<AbstractType<?>> types)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> V
build(ValueAccessor<V> accessor, boolean isStatic, V... values)
static <V> V
build(ValueAccessor<V> accessor, V... values)
java.nio.ByteBuffer
decompose(java.lang.Object... objects)
AbstractType<?>
expandUserTypes()
Replace any instances of UserType with equivalent TupleType-s.static java.nio.ByteBuffer
extractComponent(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> int
getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)
java.util.List<AbstractType<?>>
getComponents()
Return a list of the "subcomponents" this type has.static CompositeType
getInstance(java.lang.Iterable<AbstractType<?>> types)
static CompositeType
getInstance(java.util.List<AbstractType<?>> types)
static CompositeType
getInstance(AbstractType... types)
static CompositeType
getInstance(TypeParser parser)
boolean
isCompatibleWith(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> boolean
isStaticName(V value, ValueAccessor<V> accessor)
boolean
isValueCompatibleWithInternal(AbstractType<?> otherType)
Needed to handle ReversedType in value-compatibility checks.protected AbstractCompositeType.ParsedComparator
parseComparator(int i, java.lang.String part)
Used by fromStringprotected <V> boolean
readIsStatic(V value, ValueAccessor<V> accessor)
protected static <V> boolean
readIsStaticInternal(V value, ValueAccessor<V> accessor)
<V> boolean
referencesUserType(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 int
startingOffset(boolean isStatic)
protected static int
startingOffsetInternal(boolean isStatic)
java.lang.String
toString()
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 rangeCompositeType
withUpdatedUserType(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, getSerializer, getString, toJSONString, validate, validate
-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, compose, decompose, freeze, freezeNestedMulticellTypes, getString, getString, isCollection, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isReversed, isTuple, isUDT, isValueCompatibleWith, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toJSONString, toString, 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:
startingOffset
in classAbstractCompositeType
-
readIsStaticInternal
protected static <V> boolean readIsStaticInternal(V value, ValueAccessor<V> accessor)
-
readIsStatic
protected <V> boolean readIsStatic(V value, ValueAccessor<V> accessor)
- Specified by:
readIsStatic
in classAbstractCompositeType
-
getInstance
public static CompositeType getInstance(java.util.List<AbstractType<?>> types)
-
getComparator
protected <V> AbstractType<?> getComparator(int i, V value, ValueAccessor<V> accessor, int offset)
- Specified by:
getComparator
in 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:AbstractCompositeType
Adds DynamicCompositeType type information from @param bb1 to @param bb2.- Specified by:
getComparator
in 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:AbstractCompositeType
Adds type information from @param bb to @param sb. @param i is ignored.- Specified by:
getAndAppendComparator
in classAbstractCompositeType
-
parseComparator
protected AbstractCompositeType.ParsedComparator parseComparator(int i, java.lang.String part)
Description copied from class:AbstractCompositeType
Used by fromString- Specified by:
parseComparator
in classAbstractCompositeType
-
validateComparator
protected <V> AbstractType<?> validateComparator(int i, V value, ValueAccessor<V> accessor, int offset) throws MarshalException
Description copied from class:AbstractCompositeType
Like getComparator, but validates that @param i does not exceed the defined range- Specified by:
validateComparator
in classAbstractCompositeType
- Throws:
MarshalException
-
getComparatorSize
protected <V> int getComparatorSize(int i, V value, ValueAccessor<V> accessor, int offset)
- Specified by:
getComparatorSize
in classAbstractCompositeType
-
decompose
public java.nio.ByteBuffer decompose(java.lang.Object... objects)
- Specified by:
decompose
in classAbstractCompositeType
-
split
public java.nio.ByteBuffer[] split(java.nio.ByteBuffer name)
Description copied from class:AbstractCompositeType
Split a composite column names into it's components.- Overrides:
split
in 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:AbstractType
Return a list of the "subcomponents" this type has. This always return a singleton list with the type itself except for CompositeType.- Overrides:
getComponents
in classAbstractType<java.nio.ByteBuffer>
-
isCompatibleWith
public boolean isCompatibleWith(AbstractType<?> previous)
Description copied from class:AbstractType
Returns 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:
isCompatibleWith
in classAbstractType<java.nio.ByteBuffer>
-
isValueCompatibleWithInternal
public boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
Description copied from class:AbstractType
Needed to handle ReversedType in value-compatibility checks. Subclasses should implement this instead of isValueCompatibleWith().- Overrides:
isValueCompatibleWithInternal
in classAbstractType<java.nio.ByteBuffer>
-
referencesUserType
public <V> boolean referencesUserType(V name, ValueAccessor<V> accessor)
- Overrides:
referencesUserType
in classAbstractType<java.nio.ByteBuffer>
-
withUpdatedUserType
public CompositeType 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 classAbstractType<java.nio.ByteBuffer>
-
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 classAbstractType<java.nio.ByteBuffer>
-
toString
public java.lang.String toString()
Description copied from class:AbstractType
This 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:
toString
in 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)
-
-