Class Splitter


  • public abstract class Splitter
    extends java.lang.Object
    Partition splitter.
    • Constructor Detail

      • Splitter

        protected Splitter​(IPartitioner partitioner)
    • Method Detail

      • tokenForValue

        protected abstract Token tokenForValue​(java.math.BigInteger value)
      • valueForToken

        protected abstract java.math.BigInteger valueForToken​(Token token)
      • tokensInRange

        protected java.math.BigInteger tokensInRange​(Range<Token> range)
      • elapsedTokens

        protected java.math.BigInteger elapsedTokens​(Token token,
                                                     Range<Token> range)
        Computes the number of elapsed tokens from the range start until this token
        Returns:
        the number of tokens from the range start to the token
      • positionInRange

        public double positionInRange​(Token token,
                                      Range<Token> range)
        Computes the normalized position of this token relative to this range
        Returns:
        A number between 0.0 and 1.0 representing this token's position in this range or -1.0 if this range doesn't contain this token.
      • splitOwnedRanges

        public java.util.List<Token> splitOwnedRanges​(int parts,
                                                      java.util.List<Splitter.WeightedRange> weightedRanges,
                                                      boolean dontSplitRanges)
      • split

        public java.util.Set<Range<Token>> split​(java.util.Collection<Range<Token>> ranges,
                                                 int parts)
        Splits the specified token ranges in at least parts subranges.

        Each returned subrange will be contained in exactly one of the specified ranges.

        Parameters:
        ranges - a collection of token ranges to be split
        parts - the minimum number of returned ranges
        Returns:
        at least minParts token ranges covering ranges