Package org.apache.cassandra.db.marshal
Class PartitionerDefinedOrder
- java.lang.Object
-
- org.apache.cassandra.db.marshal.AbstractType<java.nio.ByteBuffer>
-
- org.apache.cassandra.db.marshal.PartitionerDefinedOrder
-
- All Implemented Interfaces:
java.util.Comparator<java.nio.ByteBuffer>
,AssignmentTestable
public class PartitionerDefinedOrder extends AbstractType<java.nio.ByteBuffer>
for sorting columns representing row keys in the row ordering as determined by a partitioner. Not intended for user-defined CFs, and will in fact error out if used with such.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.db.marshal.AbstractType
AbstractType.ComparisonType, AbstractType.DefaultArgumentDeserializer
-
Nested classes/interfaces inherited from interface org.apache.cassandra.cql3.AssignmentTestable
AssignmentTestable.TestResult
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.db.marshal.AbstractType
comparatorSet, comparisonType, isByteOrderComparable, reverseComparator
-
-
Constructor Summary
Constructors Constructor Description PartitionerDefinedOrder(IPartitioner partitioner)
PartitionerDefinedOrder(IPartitioner partitioner, AbstractType<?> partitionKeyType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> ByteSource
asComparableBytes(ValueAccessor<V> accessor, V data, ByteComparable.Version version)
Produce a byte-comparable representation of the given value, i.e.<VL,VR>
intcompareCustom(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<V> java.nio.ByteBuffer
compose(V value, ValueAccessor<V> accessor)
java.nio.ByteBuffer
decompose(java.nio.ByteBuffer value)
boolean
equals(java.lang.Object obj)
<V> V
fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
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).Term
fromJSONObject(java.lang.Object parsed)
Given a parsed JSON string, return a byte representation of the object.java.nio.ByteBuffer
fromString(java.lang.String source)
get a byte representation of the given string.ArgumentDeserializer
getArgumentDeserializer()
static AbstractType<?>
getInstance(TypeParser parser)
AbstractType<?>
getPartitionKeyType()
TypeSerializer<java.nio.ByteBuffer>
getSerializer()
<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)<V> boolean
isNull(V buffer, ValueAccessor<V> accessor)
java.lang.String
toJSONString(java.nio.ByteBuffer buffer, ProtocolVersion protocolVersion)
Converts the specified value into its JSON representation.java.lang.String
toString()
This must be overriden by subclasses if necessary so that for any AbstractType, this == TypeParser.parse(toString()).void
validate(java.nio.ByteBuffer bytes)
AbstractType<?>
withPartitionKeyType(AbstractType<?> partitionKeyType)
-
Methods inherited from class org.apache.cassandra.db.marshal.AbstractType
allowsEmpty, asComparableBytes, asCQL3Type, asCQLTypeStringList, checkComparable, compare, compare, compareCollectionMembers, compareForCQL, compose, decomposeUntyped, expandUserTypes, freeze, freezeNestedMulticellTypes, fromComparableBytes, getCompatibleTypeIfKnown, getComponents, getMaskedValue, getString, getString, isCollection, isCompatibleWith, isCounter, isEmptyValueMeaningless, isFreezable, isFrozenCollection, isMultiCell, isNull, isReversed, isSerializationCompatibleWith, isTuple, isUDT, isValueCompatibleWith, isValueCompatibleWithInternal, isValueLengthFixed, isVector, parseDefaultParameters, read, readArray, readBuffer, readBuffer, referencesDuration, referencesUserType, referencesUserType, skipValue, subTypes, testAssignment, testAssignment, toCQLString, toJSONString, toString, udfType, unfreeze, unwrap, validate, validateCellValue, validateCollectionMember, valueLengthIfFixed, withUpdatedUserType, writeValue, writeValue, writtenLength, writtenLength
-
-
-
-
Constructor Detail
-
PartitionerDefinedOrder
public PartitionerDefinedOrder(IPartitioner partitioner)
-
PartitionerDefinedOrder
public PartitionerDefinedOrder(IPartitioner partitioner, AbstractType<?> partitionKeyType)
-
-
Method Detail
-
getInstance
public static AbstractType<?> getInstance(TypeParser parser)
-
withPartitionKeyType
public AbstractType<?> withPartitionKeyType(AbstractType<?> partitionKeyType)
-
compose
public <V> java.nio.ByteBuffer compose(V value, ValueAccessor<V> accessor)
- Overrides:
compose
in classAbstractType<java.nio.ByteBuffer>
-
decompose
public java.nio.ByteBuffer decompose(java.nio.ByteBuffer value)
- Overrides:
decompose
in classAbstractType<java.nio.ByteBuffer>
-
getString
public <V> java.lang.String getString(V value, 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 classAbstractType<java.nio.ByteBuffer>
-
fromString
public java.nio.ByteBuffer fromString(java.lang.String source)
Description copied from class:AbstractType
get a byte representation of the given string.- Specified by:
fromString
in classAbstractType<java.nio.ByteBuffer>
-
fromJSONObject
public Term fromJSONObject(java.lang.Object parsed)
Description copied from class:AbstractType
Given a parsed JSON string, return a byte representation of the object.- Specified by:
fromJSONObject
in classAbstractType<java.nio.ByteBuffer>
- Parameters:
parsed
- the result of parsing a json string
-
toJSONString
public java.lang.String toJSONString(java.nio.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 classAbstractType<java.nio.ByteBuffer>
- Parameters:
buffer
- the value to convertprotocolVersion
- the protocol version to use for the conversion- Returns:
- a JSON string representing the specified value
-
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 classAbstractType<java.nio.ByteBuffer>
-
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 classAbstractType<java.nio.ByteBuffer>
-
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, anIllegalArgumentException
may be thrown.- Overrides:
fromComparableBytes
in classAbstractType<java.nio.ByteBuffer>
- 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:
AbstractType.asComparableBytes(org.apache.cassandra.db.marshal.ValueAccessor<V>, V, org.apache.cassandra.utils.bytecomparable.ByteComparable.Version)
-
validate
public void validate(java.nio.ByteBuffer bytes) throws MarshalException
- Overrides:
validate
in classAbstractType<java.nio.ByteBuffer>
- Throws:
MarshalException
-
isNull
public <V> boolean isNull(V buffer, ValueAccessor<V> accessor)
- Overrides:
isNull
in classAbstractType<java.nio.ByteBuffer>
-
getSerializer
public TypeSerializer<java.nio.ByteBuffer> getSerializer()
- Specified by:
getSerializer
in classAbstractType<java.nio.ByteBuffer>
-
getArgumentDeserializer
public ArgumentDeserializer getArgumentDeserializer()
- Overrides:
getArgumentDeserializer
in classAbstractType<java.nio.ByteBuffer>
- Returns:
- the deserializer used to deserialize the function arguments of this type.
-
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>
-
getPartitionKeyType
@Nullable public AbstractType<?> getPartitionKeyType()
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Comparator<java.nio.ByteBuffer>
- Overrides:
equals
in classjava.lang.Object
-
-