## org.apache.cassandra.dht
Class Range<T extends RingPosition>

    java.lang.Object
      org.apache.cassandra.dht.AbstractBounds<T>
          org.apache.cassandra.dht.Range<T>

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable<Range<T>>

Direct Known Subclasses:
  MerkleTree.TreeRange

    public class Range<T extends RingPosition>

extends AbstractBounds<T>
implements java.lang.Comparable<Range<T>>, java.io.Serializable

A representation of the range that a node is responsible for on the DHT ring. A Range is responsible for the tokens between (left, right]. Used by the partitioner and by map/reduce by-token range scans.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.cassandra.dht.AbstractBounds
`AbstractBounds.AbstractBoundsSerializer`

Field Summary
`static long` `serialVersionUID`

Fields inherited from class org.apache.cassandra.dht.AbstractBounds
`left, partitioner, right`

Constructor Summary
`Range(T left, T right)`
`Range(T left, T right, IPartitioner partitioner)`

Method Summary
`java.util.List<java.lang.String>` `asList()`
`int` `compareTo(Range<T> rhs)`
`boolean` `contains(Range<T> that)`
`boolean` `contains(T point)` Helps determine if a given point on the DHT ring is contained in the range in question.

`static

`<T extends RingPosition> boolean`

`

`contains(T left, T right, T point)`

`java.util.Set<Range<T>>` `differenceToFetch(Range<T> rhs)` Calculate set of the difference ranges of given two ranges (as current (A, B] and rhs is (C, D]) which node will need to fetch when moving to a given new token
`boolean` `equals(java.lang.Object o)`
`java.util.Set<Range<T>>` `intersectionWith(Range<T> that)`
`boolean` `intersects(AbstractBounds<T> that)`
`boolean` `intersects(Bounds<T> that)`
`boolean` `intersects(Range<T> that)`

`static

`<T extends RingPosition> boolean`

`

`isInRanges(T token, java.lang.Iterable<Range<T>> ranges)`

`boolean` `isWrapAround()`

`static

`<T extends RingPosition> boolean`

`

`isWrapAround(T left, T right)`
Tells if the given range is a wrap around.

`static Range<RowPosition>` `makeRowRange(Token left, Token right, IPartitioner partitioner)` Compute a range of keys corresponding to a given range of token.

`static

`<T extends RingPosition> java.util.List<Range<T>>`

`

`normalize(java.util.Collection<Range<T>> ranges)`

`static

`<T extends RingPosition> java.util.Set<Range<T>>`

`

`rangeSet(Range<T>... ranges)`

`static

`<T extends RingPosition> java.util.Set<Range<T>>`

`

`rangeSet(Range<T> range)`

`Pair<AbstractBounds<T>,AbstractBounds<T>>` `split(T position)` Given token T and AbstractBounds ?L,R?, returns Pair(?L,T], (T,R?), where ? means that the same type of AbstractBounds is returned as the original.
`java.util.Set<Range<T>>` `subtract(Range<T> rhs)`
`AbstractBounds<RowPosition>` `toRowBounds()` Transform this abstract bounds to equivalent covering bounds of row positions.
`java.lang.String` `toString()`
`AbstractBounds<Token>` `toTokenBounds()` Transform this abstract bounds to a token abstract bounds.
`java.util.List<Range<T>>` `unwrap()`

Methods inherited from class org.apache.cassandra.dht.AbstractBounds
`hashCode, intersects, serializer`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### serialVersionUID

    public static final long serialVersionUID

See Also:
  Constant Field Values

Constructor Detail

### Range

    public Range(T left,
                 T right)

### Range

    public Range(T left,
                 T right,
                 IPartitioner partitioner)

Method Detail

### contains

    public static <T extends RingPosition> boolean contains(T left,
                                                            T right,
                                                            T point)

### contains

    public boolean contains(Range<T> that)

### contains

    public boolean contains(T point)

  Helps determine if a given point on the DHT ring is contained in the range in question.

  Specified by:
    `contains` in class `AbstractBounds<T extends RingPosition>`
  Parameters:
    `point` - point in question
  Returns:
    true if the point contains within the range else false.

### intersects

    public boolean intersects(Range<T> that)

  Parameters:
    `that` - range to check for intersection
  Returns:
    true if the given range intersects with this range.

### intersects

    public boolean intersects(AbstractBounds<T> that)

### intersects

    public boolean intersects(Bounds<T> that)

  Parameters:
    `that` - range to check for intersection
  Returns:
    true if the given range intersects with this range.

### rangeSet

    public static <T extends RingPosition> java.util.Set<Range<T>> rangeSet(Range<T>... ranges)

### rangeSet

    public static <T extends RingPosition> java.util.Set<Range<T>> rangeSet(Range<T> range)

### intersectionWith

    public java.util.Set<Range<T>> intersectionWith(Range<T> that)

  Parameters:
    `that` -
  Returns:
    the intersection of the two Ranges. this can be two disjoint Ranges if one is wrapping and one is not. say you have nodes G and M, with query range (D,T]; the intersection is (M-T] and (D-G]. If there is no intersection, an empty list is returned.

### split

    public Pair<AbstractBounds<T>,AbstractBounds<T>> split(T position)

  Description copied from class: `AbstractBounds`
  Given token T and AbstractBounds ?L,R?, returns Pair(?L,T], (T,R?), where ? means that the same type of AbstractBounds is returned as the original. Put another way, returns a Pair of everything this AbstractBounds contains up to and including the split position, and everything it contains after (not including the split position). The original AbstractBounds must either contain the position T, or T should be equals to the left bound L. If the split would only yield the same AbstractBound, null is returned instead.

  Specified by:
    `split` in class `AbstractBounds<T extends RingPosition>`

### unwrap

    public java.util.List<Range<T>> unwrap()

  Specified by:
    `unwrap` in class `AbstractBounds<T extends RingPosition>`

### isWrapAround

    public static <T extends RingPosition> boolean isWrapAround(T left,
                                                                T right)

  Tells if the given range is a wrap around.

### compareTo

    public int compareTo(Range<T> rhs)

  Specified by:
    `compareTo` in interface `java.lang.Comparable<Range<T extends RingPosition>>`

### subtract

    public java.util.Set<Range<T>> subtract(Range<T> rhs)

### differenceToFetch

    public java.util.Set<Range<T>> differenceToFetch(Range<T> rhs)

  Calculate set of the difference ranges of given two ranges (as current (A, B] and rhs is (C, D]) which node will need to fetch when moving to a given new token

  Parameters:
    `rhs` - range to calculate difference
  Returns:
    set of difference ranges

### isInRanges

    public static <T extends RingPosition> boolean isInRanges(T token,
                                                              java.lang.Iterable<Range<T>> ranges)

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### asList

    public java.util.List<java.lang.String> asList()

### isWrapAround

    public boolean isWrapAround()

### normalize

    public static <T extends RingPosition> java.util.List<Range<T>> normalize(java.util.Collection<Range<T>> ranges)

  Returns:
    A copy of the given list of with all ranges unwrapped, sorted by left bound and with overlapping bounds merged.

### makeRowRange

    public static Range<RowPosition> makeRowRange(Token left,
                                                  Token right,
                                                  IPartitioner partitioner)

  Compute a range of keys corresponding to a given range of token.

### toRowBounds

    public AbstractBounds<RowPosition> toRowBounds()

  Description copied from class: `AbstractBounds`
  Transform this abstract bounds to equivalent covering bounds of row positions. If this abstract bounds was already an abstractBounds of row positions, this is a noop.

  Specified by:
    `toRowBounds` in class `AbstractBounds<T extends RingPosition>`

### toTokenBounds

    public AbstractBounds<Token> toTokenBounds()

  Description copied from class: `AbstractBounds`
  Transform this abstract bounds to a token abstract bounds. If this abstract bounds was already an abstractBounds of token, this is a noop, otherwise this use the row position tokens.

  Specified by:
    `toTokenBounds` in class `AbstractBounds<T extends RingPosition>`

Copyright © 2013 The Apache Software Foundation