Package org.apache.cassandra.dht
Class Murmur3Partitioner.LongToken
- java.lang.Object
-
- org.apache.cassandra.dht.Token
-
- org.apache.cassandra.dht.Murmur3Partitioner.LongToken
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Token>
,RingPosition<Token>
- Enclosing class:
- Murmur3Partitioner
public static class Murmur3Partitioner.LongToken extends Token
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.dht.Token
Token.KeyBound, Token.TokenFactory, Token.TokenSerializer
-
-
Field Summary
Fields Modifier and Type Field Description long
token
-
Fields inherited from class org.apache.cassandra.dht.Token
serializer
-
-
Constructor Summary
Constructors Constructor Description LongToken(long token)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteSource
asComparableBytes(ByteComparable.Version version)
Produce a weakly prefix-free byte-comparable representation of the token, i.e.int
compareTo(Token o)
Murmur3Partitioner.LongToken
decreaseSlightly()
boolean
equals(java.lang.Object obj)
long
getHeapSize()
long
getLongValue()
This method exists so that callers can access the primitivelong
value for thisToken
, if one exits.IPartitioner
getPartitioner()
java.lang.Object
getTokenValue()
int
hashCode()
static java.nio.ByteBuffer
keyForToken(long token)
static java.nio.ByteBuffer
keyForToken(Murmur3Partitioner.LongToken token)
Reverses murmur3 to find a possible 16 byte key that generates a given tokenMurmur3Partitioner.LongToken
nextValidToken()
Returns the next possible token in the token space, one that compares greater than this and such that there is no other token that sits between this token and it in the token order.double
size(Token next)
Returns a measure for the token space covered between this token and next.java.lang.String
toString()
-
Methods inherited from class org.apache.cassandra.dht.Token
getToken, isMinimum, maxKeyBound, minKeyBound, minValue
-
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(Token o)
-
asComparableBytes
public ByteSource asComparableBytes(ByteComparable.Version version)
Description copied from class:Token
Produce a weakly prefix-free byte-comparable representation of the token, i.e. such a sequence of bytes that any pair x, y of valid tokens 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.- Specified by:
asComparableBytes
in classToken
-
getPartitioner
public IPartitioner getPartitioner()
- Specified by:
getPartitioner
in interfaceRingPosition<Token>
- Specified by:
getPartitioner
in classToken
-
getHeapSize
public long getHeapSize()
- Specified by:
getHeapSize
in classToken
-
getTokenValue
public java.lang.Object getTokenValue()
- Specified by:
getTokenValue
in classToken
-
getLongValue
public long getLongValue()
Description copied from class:Token
This method exists so that callers can access the primitivelong
value for thisToken
, if one exits. It is especially useful when the auto-boxing induced by a call toToken.getTokenValue()
would be unacceptable for reasons of performance.- Overrides:
getLongValue
in classToken
- Returns:
- the primitive
long
value of this token, if one exists
-
size
public double size(Token next)
Description copied from class:Token
Returns a measure for the token space covered between this token and next. Used by the token allocation algorithm (see CASSANDRA-7032).
-
nextValidToken
public Murmur3Partitioner.LongToken nextValidToken()
Description copied from class:Token
Returns the next possible token in the token space, one that compares greater than this and such that there is no other token that sits between this token and it in the token order. This is not possible for all token types, esp. for comparison-based tokens such as the LocalPartioner used for classic secondary indexes. Used to avoid clashes between nodes in separate datacentres trying to use the same token via the token allocation algorithm, as well as in constructing token ranges for sstables.- Specified by:
nextValidToken
in classToken
-
decreaseSlightly
public Murmur3Partitioner.LongToken decreaseSlightly()
-
keyForToken
public static java.nio.ByteBuffer keyForToken(long token)
-
keyForToken
public static java.nio.ByteBuffer keyForToken(Murmur3Partitioner.LongToken token)
Reverses murmur3 to find a possible 16 byte key that generates a given token
-
-