Package org.apache.cassandra.dht
Class Murmur3Partitioner
- java.lang.Object
-
- org.apache.cassandra.dht.Murmur3Partitioner
-
- All Implemented Interfaces:
IPartitioner
public class Murmur3Partitioner extends java.lang.Object implements IPartitioner
This class generates a BigIntegerToken using a Murmur3 hash.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMurmur3Partitioner.LongToken
-
Field Summary
Fields Modifier and Type Field Description static Murmur3Partitionerinstancestatic longMAXIMUMstatic Murmur3Partitioner.LongTokenMINIMUMstatic AbstractType<?>partitionOrdering
-
Constructor Summary
Constructors Constructor Description Murmur3Partitioner()
-
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.TokengetMaximumToken()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 partitionersintgetMaxTokenSize()Murmur3Partitioner.LongTokengetMinimumToken()Murmur3Partitioner.LongTokengetRandomToken()Murmur3Partitioner.LongTokengetRandomToken(java.util.Random r)Murmur3Partitioner.LongTokengetToken(java.nio.ByteBuffer key)Generate the token of a key.Token.TokenFactorygetTokenFactory()AbstractType<?>getTokenValidator()Tokenmidpoint(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 lToken, Token rToken, double ratioToLeft)Calculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.java.util.Optional<Splitter>splitter()
-
-
-
Field Detail
-
MINIMUM
public static final Murmur3Partitioner.LongToken MINIMUM
-
MAXIMUM
public static final long MAXIMUM
- See Also:
- Constant Field Values
-
instance
public static final Murmur3Partitioner instance
-
partitionOrdering
public static final AbstractType<?> partitionOrdering
-
-
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 Token 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 lToken, Token rToken, double ratioToLeft)
Description copied from interface:IPartitionerCalculate a Token which takeapproximate 0 <= ratioToLeft <= 1ownership of the given range.- Specified by:
splitin interfaceIPartitioner
-
getMinimumToken
public Murmur3Partitioner.LongToken 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.)
-
getToken
public Murmur3Partitioner.LongToken getToken(java.nio.ByteBuffer key)
Generate the token of a key. Note that we need to ensure all generated token are strictly bigger than MINIMUM. In particular we don't want MINIMUM to correspond to any key because the range (MINIMUM, X] doesn't include MINIMUM but we use such range to select all data whose token is smaller than X.- 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
-
getRandomToken
public Murmur3Partitioner.LongToken getRandomToken()
- Specified by:
getRandomTokenin interfaceIPartitioner- Returns:
- a randomly generated token
-
getRandomToken
public Murmur3Partitioner.LongToken getRandomToken(java.util.Random r)
- Specified by:
getRandomTokenin interfaceIPartitioner- Parameters:
r- instance of Random to use when generating the token- Returns:
- a randomly generated token
-
preservesOrder
public boolean preservesOrder()
- Specified by:
preservesOrderin interfaceIPartitioner- Returns:
- True if the implementing class preserves key order in the Tokens it generates.
-
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'.
-
getTokenFactory
public Token.TokenFactory getTokenFactory()
- Specified by:
getTokenFactoryin interfaceIPartitioner
-
getTokenValidator
public AbstractType<?> getTokenValidator()
- Specified by:
getTokenValidatorin interfaceIPartitioner
-
getMaximumToken
public 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
-
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
-
splitter
public java.util.Optional<Splitter> splitter()
- Specified by:
splitterin interfaceIPartitioner
-
-