Package org.apache.cassandra.dht
Class OrderPreservingPartitioner
- java.lang.Object
-
- org.apache.cassandra.dht.OrderPreservingPartitioner
-
- All Implemented Interfaces:
IPartitioner
public class OrderPreservingPartitioner extends java.lang.Object implements IPartitioner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOrderPreservingPartitioner.StringToken
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigIntegerCHAR_MASKstatic OrderPreservingPartitionerinstancestatic OrderPreservingPartitioner.StringTokenMINIMUM
-
Constructor Summary
Constructors Constructor Description OrderPreservingPartitioner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DecoratedKeydecorateKey(java.nio.ByteBuffer key)Transform key to object representation of the on-disk format.java.util.Map<Token,java.lang.Float>describeOwnership(java.util.List<Token> sortedTokens)Calculate the deltas between tokens in the ring in order to compare relative sizes.OrderPreservingPartitioner.StringTokengetMinimumToken()OrderPreservingPartitioner.StringTokengetRandomToken()OrderPreservingPartitioner.StringTokengetRandomToken(java.util.Random random)OrderPreservingPartitioner.StringTokengetToken(java.nio.ByteBuffer key)Token.TokenFactorygetTokenFactory()AbstractType<?>getTokenValidator()OrderPreservingPartitioner.StringTokenmidpoint(Token ltoken, Token rtoken)Calculate a Token representing the approximate "middle" of the given range.AbstractType<?>partitionOrdering()Abstract type that orders the same way as DecoratedKeys provided by this partitioner.booleanpreservesOrder()Tokensplit(Token left, Token right, double ratioToLeft)Calculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.dht.IPartitioner
getMaximumToken, getMaxTokenSize, splitter
-
-
-
-
Field Detail
-
MINIMUM
public static final OrderPreservingPartitioner.StringToken MINIMUM
-
CHAR_MASK
public static final java.math.BigInteger CHAR_MASK
-
instance
public static final OrderPreservingPartitioner instance
-
-
Method Detail
-
decorateKey
public DecoratedKey decorateKey(java.nio.ByteBuffer key)
Description copied from interface:IPartitionerTransform key to object representation of the on-disk format.- Specified by:
decorateKeyin interfaceIPartitioner- Parameters:
key- the raw, client-facing key- Returns:
- decorated version of key
-
midpoint
public OrderPreservingPartitioner.StringToken midpoint(Token ltoken, Token rtoken)
Description copied from interface:IPartitionerCalculate a Token representing the approximate "middle" of the given range.- Specified by:
midpointin interfaceIPartitioner- Returns:
- The approximate midpoint between left and right.
-
split
public Token split(Token left, Token right, double ratioToLeft)
Description copied from interface:IPartitionerCalculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.- Specified by:
splitin interfaceIPartitioner
-
getMinimumToken
public OrderPreservingPartitioner.StringToken getMinimumToken()
- Specified by:
getMinimumTokenin interfaceIPartitioner- Returns:
- A Token smaller than all others in the range that is being partitioned. Not legal to assign to a node or key. (But legal to use in range scans.)
-
getRandomToken
public OrderPreservingPartitioner.StringToken getRandomToken()
- Specified by:
getRandomTokenin interfaceIPartitioner- Returns:
- a randomly generated token
-
getRandomToken
public OrderPreservingPartitioner.StringToken getRandomToken(java.util.Random random)
- Specified by:
getRandomTokenin interfaceIPartitioner- Parameters:
random- instance of Random to use when generating the token- Returns:
- a randomly generated token
-
getTokenFactory
public Token.TokenFactory getTokenFactory()
- Specified by:
getTokenFactoryin interfaceIPartitioner
-
preservesOrder
public boolean preservesOrder()
- Specified by:
preservesOrderin interfaceIPartitioner- Returns:
- True if the implementing class preserves key order in the Tokens it generates.
-
getToken
public OrderPreservingPartitioner.StringToken getToken(java.nio.ByteBuffer key)
- Specified by:
getTokenin interfaceIPartitioner- Returns:
- a Token that can be used to route a given key (This is NOT a method to create a Token from its string representation; for that, use TokenFactory.fromString.)
-
describeOwnership
public java.util.Map<Token,java.lang.Float> describeOwnership(java.util.List<Token> sortedTokens)
Description copied from interface:IPartitionerCalculate the deltas between tokens in the ring in order to compare relative sizes.- Specified by:
describeOwnershipin interfaceIPartitioner- Parameters:
sortedTokens- a sorted List of Tokens- Returns:
- the mapping from 'token' to 'percentage of the ring owned by that token'.
-
getTokenValidator
public AbstractType<?> getTokenValidator()
- Specified by:
getTokenValidatorin interfaceIPartitioner
-
partitionOrdering
public AbstractType<?> partitionOrdering()
Description copied from interface:IPartitionerAbstract type that orders the same way as DecoratedKeys provided by this partitioner. Used by secondary indices.- Specified by:
partitionOrderingin interfaceIPartitioner
-
-