org.apache.cassandra.dht
Class RandomPartitioner
java.lang.Object
org.apache.cassandra.dht.RandomPartitioner
- All Implemented Interfaces:
- IPartitioner<BigIntegerToken>
public class RandomPartitioner
- extends java.lang.Object
- implements IPartitioner<BigIntegerToken>
This class generates a BigIntegerToken using MD5 hash.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TWO
public static final java.math.BigInteger TWO
MD5_MAX
public static final java.math.BigInteger MD5_MAX
MINIMUM
public static final BigIntegerToken MINIMUM
RandomPartitioner
public RandomPartitioner()
decorateKey
public java.lang.String decorateKey(java.lang.String key)
- Description copied from interface:
IPartitioner
- Transform key to on-disk format s.t. keys are stored in node comparison order.
This lets bootstrap rip out parts of the sstable sequentially instead of doing random seeks.
- Specified by:
decorateKey
in interface IPartitioner<BigIntegerToken>
- Parameters:
key
- the raw, client-facing key
- Returns:
- decorated on-disk version of key
undecorateKey
public java.lang.String undecorateKey(java.lang.String decoratedKey)
- Specified by:
undecorateKey
in interface IPartitioner<BigIntegerToken>
getDecoratedKeyComparator
public java.util.Comparator<java.lang.String> getDecoratedKeyComparator()
- Specified by:
getDecoratedKeyComparator
in interface IPartitioner<BigIntegerToken>
getReverseDecoratedKeyComparator
public java.util.Comparator<java.lang.String> getReverseDecoratedKeyComparator()
- Specified by:
getReverseDecoratedKeyComparator
in interface IPartitioner<BigIntegerToken>
midpoint
public BigIntegerToken midpoint(BigIntegerToken ltoken,
BigIntegerToken rtoken)
- Description copied from interface:
IPartitioner
- Calculate a Token representing the approximate "middle" of the given
range.
The Tokens must have been generated by previous calls to midpoint,
or be equal to this.getMinimumToken(). The range may not wrap unless it
involves this.getMinimumToken().
- Specified by:
midpoint
in interface IPartitioner<BigIntegerToken>
- Returns:
- The approximate midpoint between left and right.
getMinimumToken
public BigIntegerToken getMinimumToken()
- Specified by:
getMinimumToken
in interface IPartitioner<BigIntegerToken>
- Returns:
- The minimum possible Token in the range that is being partitioned.
getDefaultToken
public BigIntegerToken getDefaultToken()
- Specified by:
getDefaultToken
in interface IPartitioner<BigIntegerToken>
- Returns:
- the default Token to represent this node if none was saved.
Uses the one given in the InitialToken configuration directive,
or picks one automatically if that was not given.
getTokenFactory
public Token.TokenFactory<java.math.BigInteger> getTokenFactory()
- Specified by:
getTokenFactory
in interface IPartitioner<BigIntegerToken>
preservesOrder
public boolean preservesOrder()
- Specified by:
preservesOrder
in interface IPartitioner<BigIntegerToken>
- Returns:
- True if the implementing class preserves key order in the Tokens
it generates.
getToken
public BigIntegerToken getToken(java.lang.String key)
- Specified by:
getToken
in interface IPartitioner<BigIntegerToken>
- Returns:
- a Token that can be used to route a given key
Copyright © 2009 The Apache Software Foundation