Package org.apache.cassandra.dht
Class AbstractBounds<T extends RingPosition<T>>
- java.lang.Object
-
- org.apache.cassandra.dht.AbstractBounds<T>
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Bounds
,ExcludingBounds
,IncludingExcludingBounds
,Range
public abstract class AbstractBounds<T extends RingPosition<T>> extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractBounds.AbstractBoundsSerializer<T extends RingPosition<T>>
static class
AbstractBounds.Boundary<T extends RingPosition<T>>
-
Field Summary
Fields Modifier and Type Field Description T
left
T
right
static IPartitionerDependentSerializer<AbstractBounds<PartitionPosition>>
rowPositionSerializer
static IPartitionerDependentSerializer<AbstractBounds<Token>>
tokenSerializer
-
Constructor Summary
Constructors Constructor Description AbstractBounds(T left, T right)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T extends RingPosition<T>>
AbstractBounds<T>bounds(AbstractBounds.Boundary<T> min, AbstractBounds.Boundary<T> max)
static <T extends RingPosition<T>>
AbstractBounds<T>bounds(T min, boolean inclusiveMin, T max, boolean inclusiveMax)
abstract boolean
contains(T start)
protected abstract java.lang.String
getClosingString()
protected abstract java.lang.String
getOpeningString()
java.lang.String
getString(AbstractType<?> keyValidator)
int
hashCode()
abstract boolean
inclusiveLeft()
abstract boolean
inclusiveRight()
boolean
intersects(java.lang.Iterable<Range<T>> ranges)
return true if @param range intersects any of the given @param rangesstatic <T extends RingPosition<T>>
booleanisEmpty(AbstractBounds.Boundary<T> left, AbstractBounds.Boundary<T> right)
abstract boolean
isEndInclusive()
abstract boolean
isStartInclusive()
AbstractBounds.Boundary<T>
leftBoundary()
static <T extends RingPosition<T>>
AbstractBounds.Boundary<T>maxLeft(AbstractBounds.Boundary<T> left1, AbstractBounds.Boundary<T> left2)
static <T extends RingPosition<T>>
AbstractBounds.Boundary<T>maxLeft(AbstractBounds.Boundary<T> left1, T left2, boolean isInclusiveLeft2)
static <T extends RingPosition<T>>
AbstractBounds.Boundary<T>minRight(AbstractBounds.Boundary<T> right1, AbstractBounds.Boundary<T> right2)
static <T extends RingPosition<T>>
AbstractBounds.Boundary<T>minRight(AbstractBounds.Boundary<T> right1, T right2, boolean isInclusiveRight2)
static <T extends RingPosition<T>>
booleannoneStrictlyWrapsAround(java.util.Collection<AbstractBounds<T>> bounds)
AbstractBounds.Boundary<T>
rightBoundary()
abstract 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.static <T extends RingPosition<T>>
booleanstrictlyWrapsAround(T left, T right)
Whetherleft
andright
forms a wrapping interval, that is if unwrapping wouldn't be a no-op.abstract java.util.List<? extends AbstractBounds<T>>
unwrap()
abstract AbstractBounds<T>
withNewRight(T newRight)
-
-
-
Field Detail
-
tokenSerializer
public static final IPartitionerDependentSerializer<AbstractBounds<Token>> tokenSerializer
-
rowPositionSerializer
public static final IPartitionerDependentSerializer<AbstractBounds<PartitionPosition>> rowPositionSerializer
-
left
public final T extends RingPosition<T> left
-
right
public final T extends RingPosition<T> right
-
-
Method Detail
-
split
public abstract 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. 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.
-
inclusiveLeft
public abstract boolean inclusiveLeft()
-
inclusiveRight
public abstract boolean inclusiveRight()
-
strictlyWrapsAround
public static <T extends RingPosition<T>> boolean strictlyWrapsAround(T left, T right)
Whetherleft
andright
forms a wrapping interval, that is if unwrapping wouldn't be a no-op.Note that the semantic is slightly different from
Range.isWrapAround()
in the sense that if bothright
are minimal (for the partitioner), this methods return false (doesn't wrap) whileRange.isWrapAround()
returns true (does wrap). This is confusing and we should fix it by refactoring/rewriting the whole AbstractBounds hierarchy with cleaner semantics, but we don't want to risk breaking something by changingRange.isWrapAround()
in the meantime.
-
noneStrictlyWrapsAround
public static <T extends RingPosition<T>> boolean noneStrictlyWrapsAround(java.util.Collection<AbstractBounds<T>> bounds)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
intersects
public boolean intersects(java.lang.Iterable<Range<T>> ranges)
return true if @param range intersects any of the given @param ranges
-
contains
public abstract boolean contains(T start)
-
unwrap
public abstract java.util.List<? extends AbstractBounds<T>> unwrap()
-
getString
public java.lang.String getString(AbstractType<?> keyValidator)
-
getOpeningString
protected abstract java.lang.String getOpeningString()
-
getClosingString
protected abstract java.lang.String getClosingString()
-
isStartInclusive
public abstract boolean isStartInclusive()
-
isEndInclusive
public abstract boolean isEndInclusive()
-
withNewRight
public abstract AbstractBounds<T> withNewRight(T newRight)
-
bounds
public static <T extends RingPosition<T>> AbstractBounds<T> bounds(AbstractBounds.Boundary<T> min, AbstractBounds.Boundary<T> max)
-
bounds
public static <T extends RingPosition<T>> AbstractBounds<T> bounds(T min, boolean inclusiveMin, T max, boolean inclusiveMax)
-
leftBoundary
public AbstractBounds.Boundary<T> leftBoundary()
-
rightBoundary
public AbstractBounds.Boundary<T> rightBoundary()
-
isEmpty
public static <T extends RingPosition<T>> boolean isEmpty(AbstractBounds.Boundary<T> left, AbstractBounds.Boundary<T> right)
-
minRight
public static <T extends RingPosition<T>> AbstractBounds.Boundary<T> minRight(AbstractBounds.Boundary<T> right1, T right2, boolean isInclusiveRight2)
-
minRight
public static <T extends RingPosition<T>> AbstractBounds.Boundary<T> minRight(AbstractBounds.Boundary<T> right1, AbstractBounds.Boundary<T> right2)
-
maxLeft
public static <T extends RingPosition<T>> AbstractBounds.Boundary<T> maxLeft(AbstractBounds.Boundary<T> left1, T left2, boolean isInclusiveLeft2)
-
maxLeft
public static <T extends RingPosition<T>> AbstractBounds.Boundary<T> maxLeft(AbstractBounds.Boundary<T> left1, AbstractBounds.Boundary<T> left2)
-
-