org.apache.cassandra.dht
Interface IPartitioner<T extends Token>

All Known Implementing Classes:
CollatingOrderPreservingPartitioner, OrderPreservingPartitioner, RandomPartitioner

public interface IPartitioner<T extends Token>


Method Summary
 DecoratedKey<T> convertFromDiskFormat(java.lang.String key)
          Convert the on disk representation to a DecoratedKey object
 java.lang.String convertToDiskFormat(DecoratedKey<T> key)
          Convert the DecoratedKey to the on disk format used for this partitioner.
 DecoratedKey<T> decorateKey(java.lang.String key)
          Transform key to object representation of the on-disk format.
 java.util.Comparator<DecoratedKey<T>> getDecoratedKeyComparator()
           
 T getMinimumToken()
           
 T getRandomToken()
           
 T getToken(java.lang.String key)
           
 Token.TokenFactory getTokenFactory()
           
 T midpoint(T left, T right)
          Calculate a Token representing the approximate "middle" of the given range.
 boolean preservesOrder()
           
 

Method Detail

convertFromDiskFormat

DecoratedKey<T> convertFromDiskFormat(java.lang.String key)
Convert the on disk representation to a DecoratedKey object

Parameters:
key - On disk representation
Returns:
DecoratedKey object

convertToDiskFormat

java.lang.String convertToDiskFormat(DecoratedKey<T> key)
Convert the DecoratedKey to the on disk format used for this partitioner.

Parameters:
key - The DecoratedKey in question
Returns:

decorateKey

DecoratedKey<T> decorateKey(java.lang.String key)
Transform key to object representation of the on-disk format.

Parameters:
key - the raw, client-facing key
Returns:
decorated version of key

getDecoratedKeyComparator

java.util.Comparator<DecoratedKey<T>> getDecoratedKeyComparator()
Returns:
a comparator for decorated key objects, not strings

midpoint

T midpoint(T left,
           T right)
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().

Returns:
The approximate midpoint between left and right.

getMinimumToken

T getMinimumToken()
Returns:
The minimum possible Token in the range that is being partitioned.

getToken

T getToken(java.lang.String key)
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

T getRandomToken()
Returns:
a randomly generated token

getTokenFactory

Token.TokenFactory getTokenFactory()

preservesOrder

boolean preservesOrder()
Returns:
True if the implementing class preserves key order in the Tokens it generates.


Copyright © 2009 The Apache Software Foundation