Package org.apache.cassandra.dht
Class LocalPartitioner
- java.lang.Object
-
- org.apache.cassandra.dht.LocalPartitioner
-
- All Implemented Interfaces:
IPartitioner
public class LocalPartitioner extends java.lang.Object implements IPartitioner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
LocalPartitioner.LocalToken
-
Constructor Summary
Constructors Constructor Description LocalPartitioner(AbstractType<?> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DecoratedKey
decorateKey(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.LocalPartitioner.LocalToken
getMinimumToken()
LocalPartitioner.LocalToken
getRandomToken()
LocalPartitioner.LocalToken
getRandomToken(java.util.Random random)
LocalPartitioner.LocalToken
getToken(java.nio.ByteBuffer key)
Token.TokenFactory
getTokenFactory()
AbstractType<?>
getTokenValidator()
Token
midpoint(Token left, Token right)
Calculate a Token representing the approximate "middle" of the given range.AbstractType<?>
partitionOrdering()
boolean
preservesOrder()
Token
split(Token left, Token right, double ratioToLeft)
Calculate a Token which takeapproximate 0 <= ratioToLeft <= 1
ownership 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, partitionOrdering, splitter
-
-
-
-
Constructor Detail
-
LocalPartitioner
public LocalPartitioner(AbstractType<?> comparator)
-
-
Method Detail
-
decorateKey
public DecoratedKey decorateKey(java.nio.ByteBuffer key)
Description copied from interface:IPartitioner
Transform key to object representation of the on-disk format.- Specified by:
decorateKey
in interfaceIPartitioner
- Parameters:
key
- the raw, client-facing key- Returns:
- decorated version of key
-
midpoint
public Token midpoint(Token left, Token right)
Description copied from interface:IPartitioner
Calculate a Token representing the approximate "middle" of the given range.- Specified by:
midpoint
in interfaceIPartitioner
- Returns:
- The approximate midpoint between left and right.
-
split
public Token split(Token left, Token right, double ratioToLeft)
Description copied from interface:IPartitioner
Calculate a Token which takeapproximate 0 <= ratioToLeft <= 1
ownership of the given range.- Specified by:
split
in interfaceIPartitioner
-
getMinimumToken
public LocalPartitioner.LocalToken getMinimumToken()
- Specified by:
getMinimumToken
in 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 LocalPartitioner.LocalToken getToken(java.nio.ByteBuffer key)
- Specified by:
getToken
in 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.)
-
getRandomToken
public LocalPartitioner.LocalToken getRandomToken()
- Specified by:
getRandomToken
in interfaceIPartitioner
- Returns:
- a randomly generated token
-
getRandomToken
public LocalPartitioner.LocalToken getRandomToken(java.util.Random random)
- Specified by:
getRandomToken
in interfaceIPartitioner
- Parameters:
random
- instance of Random to use when generating the token- Returns:
- a randomly generated token
-
getTokenFactory
public Token.TokenFactory getTokenFactory()
- Specified by:
getTokenFactory
in interfaceIPartitioner
-
preservesOrder
public boolean preservesOrder()
- Specified by:
preservesOrder
in 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:IPartitioner
Calculate the deltas between tokens in the ring in order to compare relative sizes.- Specified by:
describeOwnership
in 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:
getTokenValidator
in interfaceIPartitioner
-
partitionOrdering
public AbstractType<?> partitionOrdering()
- Specified by:
partitionOrdering
in interfaceIPartitioner
-
-