Package org.apache.cassandra.db
Class DecoratedKey
- java.lang.Object
-
- org.apache.cassandra.db.DecoratedKey
-
- All Implemented Interfaces:
java.lang.Comparable<PartitionPosition>,PartitionPosition,RingPosition<PartitionPosition>,IFilter.FilterKey
- Direct Known Subclasses:
BufferDecoratedKey,NativeDecoratedKey
public abstract class DecoratedKey extends java.lang.Object implements PartitionPosition, IFilter.FilterKey
Represents a decorated key, handy for certain operations where just working with strings gets slow. We do a lot of sorting of DecoratedKeys, so for speed, we assume that tokens correspond one-to-one with keys. This is not quite correct in the case of RandomPartitioner (which uses MD5 to hash keys to tokens); if this matters, you can subclass RP to use a stronger hash, or use a non-lossy tokenization scheme (as in the OrderPreservingPartitioner classes).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.cassandra.db.PartitionPosition
PartitionPosition.ForKey, PartitionPosition.Kind, PartitionPosition.RowPositionSerializer
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<DecoratedKey>comparator-
Fields inherited from interface org.apache.cassandra.db.PartitionPosition
serializer
-
-
Constructor Summary
Constructors Constructor Description DecoratedKey(Token token)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(PartitionPosition pos)static intcompareTo(IPartitioner partitioner, java.nio.ByteBuffer key, PartitionPosition position)booleanequals(java.lang.Object obj)voidfilterHash(long[] dest)Places the murmur3 hash of the key in the given long array of size at least two.abstract java.nio.ByteBuffergetKey()IPartitionergetPartitioner()TokengetToken()inthashCode()booleanisMinimum()PartitionPosition.Kindkind()Token.KeyBoundminValue()java.lang.StringtoCQLString(TableMetadata metadata)Returns a CQL representation of this key.java.lang.StringtoString()
-
-
-
Field Detail
-
comparator
public static final java.util.Comparator<DecoratedKey> comparator
-
-
Constructor Detail
-
DecoratedKey
public DecoratedKey(Token token)
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(PartitionPosition pos)
- Specified by:
compareToin interfacejava.lang.Comparable<PartitionPosition>
-
compareTo
public static int compareTo(IPartitioner partitioner, java.nio.ByteBuffer key, PartitionPosition position)
-
getPartitioner
public IPartitioner getPartitioner()
- Specified by:
getPartitionerin interfaceRingPosition<PartitionPosition>
-
minValue
public Token.KeyBound minValue()
- Specified by:
minValuein interfaceRingPosition<PartitionPosition>
-
isMinimum
public boolean isMinimum()
- Specified by:
isMinimumin interfacePartitionPosition- Specified by:
isMinimumin interfaceRingPosition<PartitionPosition>
-
kind
public PartitionPosition.Kind kind()
- Specified by:
kindin interfacePartitionPosition
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toCQLString
public java.lang.String toCQLString(TableMetadata metadata)
Returns a CQL representation of this key.- Parameters:
metadata- the metadata of the table that this key belogs to- Returns:
- a CQL representation of this key
-
getToken
public Token getToken()
- Specified by:
getTokenin interfaceRingPosition<PartitionPosition>
-
getKey
public abstract java.nio.ByteBuffer getKey()
-
filterHash
public void filterHash(long[] dest)
Description copied from interface:IFilter.FilterKeyPlaces the murmur3 hash of the key in the given long array of size at least two.- Specified by:
filterHashin interfaceIFilter.FilterKey
-
-