public abstract class AbstractType<T> extends java.lang.Object implements java.util.Comparator<java.nio.ByteBuffer>, AssignmentTestable
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractType.ComparisonType |
AssignmentTestable.TestResult| Modifier and Type | Field and Description |
|---|---|
ValueComparators |
comparatorSet |
AbstractType.ComparisonType |
comparisonType |
boolean |
isByteOrderComparable |
java.util.Comparator<java.nio.ByteBuffer> |
reverseComparator |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractType(AbstractType.ComparisonType comparisonType) |
| Modifier and Type | Method and Description |
|---|---|
CQL3Type |
asCQL3Type() |
static java.util.List<java.lang.String> |
asCQLTypeStringList(java.util.List<AbstractType<?>> abstractTypes) |
void |
checkComparable() |
int |
compare(java.nio.ByteBuffer left,
java.nio.ByteBuffer right) |
<VL,VR> int |
compare(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR) |
<VL,VR> int |
compareCollectionMembers(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR,
VL collectionName)
An alternative comparison function used by CollectionsType in conjunction with CompositeType.
|
<VL,VR> int |
compareCustom(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR)
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
|
int |
compareForCQL(java.nio.ByteBuffer v1,
java.nio.ByteBuffer v2)
Same as compare except that this ignore ReversedType.
|
T |
compose(java.nio.ByteBuffer bytes) |
<V> T |
compose(V value,
ValueAccessor<V> accessor) |
java.nio.ByteBuffer |
decompose(T value) |
AbstractType<?> |
expandUserTypes()
Replace any instances of UserType with equivalent TupleType-s.
|
AbstractType<?> |
freeze() |
AbstractType<?> |
freezeNestedMulticellTypes()
Returns an AbstractType instance that is equivalent to this one, but with all nested UDTs and collections
explicitly frozen.
|
abstract Term |
fromJSONObject(java.lang.Object parsed)
Given a parsed JSON string, return a byte representation of the object.
|
abstract java.nio.ByteBuffer |
fromString(java.lang.String source)
get a byte representation of the given string.
|
java.util.List<AbstractType<?>> |
getComponents()
Return a list of the "subcomponents" this type has.
|
abstract TypeSerializer<T> |
getSerializer() |
java.lang.String |
getString(java.nio.ByteBuffer bytes) |
java.lang.String |
getString(java.util.Collection<java.nio.ByteBuffer> names) |
<V> java.lang.String |
getString(V value,
ValueAccessor<V> accessor)
get a string representation of the bytes used for various identifier (NOT just for log messages)
|
boolean |
isCollection() |
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.
|
boolean |
isCounter() |
boolean |
isEmptyValueMeaningless()
|
boolean |
isFreezable() |
boolean |
isFrozenCollection() |
boolean |
isMultiCell() |
boolean |
isReversed() |
boolean |
isTuple() |
boolean |
isUDT() |
boolean |
isValueCompatibleWith(AbstractType<?> otherType)
Returns true if values of the other AbstractType can be read and "reasonably" interpreted by the this
AbstractType.
|
protected boolean |
isValueCompatibleWithInternal(AbstractType<?> otherType)
Needed to handle ReversedType in value-compatibility checks.
|
static AbstractType<?> |
parseDefaultParameters(AbstractType<?> baseType,
TypeParser parser) |
<V> V |
read(ValueAccessor<V> accessor,
DataInputPlus in,
int maxValueSize) |
byte[] |
readArray(DataInputPlus in,
int maxValueSize) |
java.nio.ByteBuffer |
readBuffer(DataInputPlus in) |
java.nio.ByteBuffer |
readBuffer(DataInputPlus in,
int maxValueSize) |
boolean |
referencesDuration() |
boolean |
referencesUserType(java.nio.ByteBuffer name) |
<V> boolean |
referencesUserType(V name,
ValueAccessor<V> accessor) |
void |
skipValue(DataInputPlus in) |
java.util.List<AbstractType<?>> |
subTypes() |
AssignmentTestable.TestResult |
testAssignment(AbstractType<?> receiverType)
Tests whether a CQL value having this type can be assigned to the provided receiver.
|
AssignmentTestable.TestResult |
testAssignment(java.lang.String keyspace,
ColumnSpecification receiver) |
java.lang.String |
toJSONString(java.nio.ByteBuffer buffer,
ProtocolVersion protocolVersion)
Converts the specified value into its JSON representation.
|
<V> java.lang.String |
toJSONString(V value,
ValueAccessor<V> accessor,
ProtocolVersion protocolVersion) |
java.lang.String |
toString()
This must be overriden by subclasses if necessary so that for any
AbstractType, this == TypeParser.parse(toString()).
|
java.lang.String |
toString(boolean ignoreFreezing) |
void |
validate(java.nio.ByteBuffer bytes) |
<V> void |
validate(V value,
ValueAccessor<V> accessor) |
<V> void |
validateCellValue(V cellValue,
ValueAccessor<V> accessor)
Validate cell value.
|
<V> void |
validateCollectionMember(V value,
V collectionName,
ValueAccessor<V> accessor) |
int |
valueLengthIfFixed()
The length of values for this type if all values are of fixed length, -1 otherwise.
|
AbstractType<?> |
withUpdatedUserType(UserType udt)
Returns an instance of this type with all references to the provided user type recursively replaced with its new
definition.
|
void |
writeValue(java.nio.ByteBuffer value,
DataOutputPlus out) |
<V> void |
writeValue(V value,
ValueAccessor<V> accessor,
DataOutputPlus out) |
long |
writtenLength(java.nio.ByteBuffer value) |
<V> long |
writtenLength(V value,
ValueAccessor<V> accessor) |
public final java.util.Comparator<java.nio.ByteBuffer> reverseComparator
public final AbstractType.ComparisonType comparisonType
public final boolean isByteOrderComparable
public final ValueComparators comparatorSet
protected AbstractType(AbstractType.ComparisonType comparisonType)
public static java.util.List<java.lang.String> asCQLTypeStringList(java.util.List<AbstractType<?>> abstractTypes)
public final T compose(java.nio.ByteBuffer bytes)
public <V> T compose(V value, ValueAccessor<V> accessor)
public java.nio.ByteBuffer decompose(T value)
public <V> java.lang.String getString(V value,
ValueAccessor<V> accessor)
public final java.lang.String getString(java.nio.ByteBuffer bytes)
public abstract java.nio.ByteBuffer fromString(java.lang.String source)
throws MarshalException
MarshalExceptionpublic abstract Term fromJSONObject(java.lang.Object parsed) throws MarshalException
parsed - the result of parsing a json stringMarshalExceptionpublic java.lang.String toJSONString(java.nio.ByteBuffer buffer,
ProtocolVersion protocolVersion)
The buffer position will stay the same.
buffer - the value to convertprotocolVersion - the protocol version to use for the conversionpublic <V> java.lang.String toJSONString(V value,
ValueAccessor<V> accessor,
ProtocolVersion protocolVersion)
public void validate(java.nio.ByteBuffer bytes)
throws MarshalException
MarshalExceptionpublic <V> void validate(V value,
ValueAccessor<V> accessor)
throws MarshalException
MarshalExceptionpublic final int compare(java.nio.ByteBuffer left,
java.nio.ByteBuffer right)
compare in interface java.util.Comparator<java.nio.ByteBuffer>public final <VL,VR> int compare(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR)
public <VL,VR> int compareCustom(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR)
left - accessorL - right - accessorR - public <V> void validateCellValue(V cellValue,
ValueAccessor<V> accessor)
throws MarshalException
cellValue - ByteBuffer representing cell valueMarshalExceptionpublic CQL3Type asCQL3Type()
public int compareForCQL(java.nio.ByteBuffer v1,
java.nio.ByteBuffer v2)
public abstract TypeSerializer<T> getSerializer()
public java.lang.String getString(java.util.Collection<java.nio.ByteBuffer> names)
public boolean isCounter()
public boolean isFrozenCollection()
public boolean isReversed()
public static AbstractType<?> parseDefaultParameters(AbstractType<?> baseType, TypeParser parser) throws SyntaxException
SyntaxExceptionpublic boolean isCompatibleWith(AbstractType<?> previous)
public boolean isValueCompatibleWith(AbstractType<?> otherType)
protected boolean isValueCompatibleWithInternal(AbstractType<?> otherType)
public <VL,VR> int compareCollectionMembers(VL left,
ValueAccessor<VL> accessorL,
VR right,
ValueAccessor<VR> accessorR,
VL collectionName)
public <V> void validateCollectionMember(V value,
V collectionName,
ValueAccessor<V> accessor)
throws MarshalException
MarshalExceptionpublic boolean isCollection()
public boolean isUDT()
public boolean isTuple()
public boolean isMultiCell()
public boolean isFreezable()
public AbstractType<?> freeze()
public java.util.List<AbstractType<?>> subTypes()
public AbstractType<?> freezeNestedMulticellTypes()
2.x -> 3.x schema migrations, and can be removed in Cassandra 4.0.
See CASSANDRA-11609 and CASSANDRA-11613.public boolean isEmptyValueMeaningless()
public java.lang.String toString(boolean ignoreFreezing)
ignoreFreezing - if true, the type string will not be wrapped with FrozenType(...), even if this type is frozen.public java.util.List<AbstractType<?>> getComponents()
public int valueLengthIfFixed()
public void writeValue(java.nio.ByteBuffer value,
DataOutputPlus out)
throws java.io.IOException
java.io.IOExceptionpublic <V> void writeValue(V value,
ValueAccessor<V> accessor,
DataOutputPlus out)
throws java.io.IOException
java.io.IOExceptionpublic long writtenLength(java.nio.ByteBuffer value)
public <V> long writtenLength(V value,
ValueAccessor<V> accessor)
public java.nio.ByteBuffer readBuffer(DataInputPlus in) throws java.io.IOException
java.io.IOExceptionpublic java.nio.ByteBuffer readBuffer(DataInputPlus in, int maxValueSize) throws java.io.IOException
java.io.IOExceptionpublic byte[] readArray(DataInputPlus in, int maxValueSize) throws java.io.IOException
java.io.IOExceptionpublic <V> V read(ValueAccessor<V> accessor, DataInputPlus in, int maxValueSize) throws java.io.IOException
java.io.IOExceptionpublic void skipValue(DataInputPlus in) throws java.io.IOException
java.io.IOExceptionpublic final boolean referencesUserType(java.nio.ByteBuffer name)
public <V> boolean referencesUserType(V name,
ValueAccessor<V> accessor)
public AbstractType<?> withUpdatedUserType(UserType udt)
public AbstractType<?> expandUserTypes()
public boolean referencesDuration()
public AssignmentTestable.TestResult testAssignment(AbstractType<?> receiverType)
public java.lang.String toString()
toString in class java.lang.Objectpublic void checkComparable()
public final AssignmentTestable.TestResult testAssignment(java.lang.String keyspace, ColumnSpecification receiver)
testAssignment in interface AssignmentTestableCopyright © 2009-2020 The Apache Software Foundation