Package org.apache.cassandra.dht
Class RandomPartitioner
java.lang.Object
org.apache.cassandra.dht.RandomPartitioner
- All Implemented Interfaces:
IPartitioner
This class generates a BigIntegerToken using MD5 hash.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RandomPartitionerstatic final BigIntegerstatic final intstatic final RandomPartitioner.BigIntegerTokenstatic final PartitionerDefinedOrderstatic final BigInteger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecorateKey(ByteBuffer key) Transform key to object representation of the on-disk format.describeOwnership(List<Token> sortedTokens) Calculate the deltas between tokens in the ring in order to compare relative sizes.The biggest token for this partitioner, unlike getMinimumToken, this token is actually used and users wanting to include all tokens need to do getMaximumToken().maxKeyBound() Not implemented for the ordered partitionersintgetRandomToken(Random random) getToken(ByteBuffer key) AbstractType<?>Calculate a Token representing the approximate "middle" of the given range.AbstractType<?>AbstractType<?>partitionOrdering(AbstractType<?> partitionKeyType) Abstract type that orders the same way as DecoratedKeys provided by this partitioner.booleanCalculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.splitter()
-
Field Details
-
ZERO
-
MINIMUM
-
MAXIMUM
-
MAXIMUM_TOKEN_SIZE
public static final int MAXIMUM_TOKEN_SIZE -
instance
-
partitionOrdering
-
-
Constructor Details
-
RandomPartitioner
public RandomPartitioner()
-
-
Method Details
-
decorateKey
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
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
Description copied from interface:IPartitionerCalculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.- Specified by:
splitin interfaceIPartitioner
-
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
- Specified by:
getRandomTokenin interfaceIPartitioner- Returns:
- a randomly generated token
-
getRandomToken
- Specified by:
getRandomTokenin interfaceIPartitioner- Parameters:
random- instance of Random to use when generating the token- Returns:
- a randomly generated token
-
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
- 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.)
-
getMaxTokenSize
public int getMaxTokenSize()- Specified by:
getMaxTokenSizein interfaceIPartitioner
-
describeOwnership
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'.
-
getMaximumToken
Description copied from interface:IPartitionerThe biggest token for this partitioner, unlike getMinimumToken, this token is actually used and users wanting to include all tokens need to do getMaximumToken().maxKeyBound() Not implemented for the ordered partitioners- Specified by:
getMaximumTokenin interfaceIPartitioner
-
getTokenValidator
- Specified by:
getTokenValidatorin interfaceIPartitioner
-
partitionOrdering
- Specified by:
partitionOrderingin interfaceIPartitioner
-
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- Parameters:
partitionKeyType- partition key type for PartitionerDefinedOrder
-
splitter
- Specified by:
splitterin interfaceIPartitioner
-