use of org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken in project cassandra by apache.
the class RangeTest method testNoIntersection.
@Test
public void testNoIntersection() {
Range<Token> wraps1 = new Range<Token>(new BigIntegerToken("100"), new BigIntegerToken("10"));
Range<Token> wraps2 = new Range<Token>(new BigIntegerToken("100"), new BigIntegerToken("0"));
Range<Token> nowrap1 = new Range<Token>(new BigIntegerToken("0"), new BigIntegerToken("100"));
Range<Token> nowrap2 = new Range<Token>(new BigIntegerToken("100"), new BigIntegerToken("200"));
Range<Token> nowrap3 = new Range<Token>(new BigIntegerToken("10"), new BigIntegerToken("100"));
assertNoIntersection(wraps1, nowrap3);
assertNoIntersection(wraps2, nowrap1);
assertNoIntersection(nowrap1, nowrap2);
}
use of org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken in project cassandra by apache.
the class RangeTest method testContainsRangeWrapping.
@Test
public void testContainsRangeWrapping() {
Range<Token> one = new Range<Token>(new BigIntegerToken("10"), new BigIntegerToken("2"));
Range<Token> two = new Range<Token>(new BigIntegerToken("5"), new BigIntegerToken("3"));
Range<Token> thr = new Range<Token>(new BigIntegerToken("10"), new BigIntegerToken("12"));
Range<Token> fou = new Range<Token>(new BigIntegerToken("2"), new BigIntegerToken("6"));
Range<Token> fiv = new Range<Token>(new BigIntegerToken("0"), new BigIntegerToken("0"));
assert !one.contains(two);
assert one.contains(thr);
assert !one.contains(fou);
assert two.contains(one);
assert two.contains(thr);
assert !two.contains(fou);
assert !thr.contains(one);
assert !thr.contains(two);
assert !thr.contains(fou);
assert !fou.contains(one);
assert !fou.contains(two);
assert !fou.contains(thr);
assert fiv.contains(one);
assert fiv.contains(two);
assert fiv.contains(thr);
assert fiv.contains(fou);
}
use of org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken in project cassandra by apache.
the class RangeTest method testContainsWrapping.
@Test
public void testContainsWrapping() {
Range<Token> range = new Range<Token>(new BigIntegerToken("0"), new BigIntegerToken("0"));
assert range.contains(new BigIntegerToken("0"));
assert range.contains(new BigIntegerToken("10"));
assert range.contains(new BigIntegerToken("100"));
assert range.contains(new BigIntegerToken("101"));
range = new Range<Token>(new BigIntegerToken("100"), new BigIntegerToken("0"));
assert range.contains(new BigIntegerToken("0"));
assert !range.contains(new BigIntegerToken("1"));
assert !range.contains(new BigIntegerToken("100"));
assert range.contains(new BigIntegerToken("200"));
}
use of org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken in project cassandra by apache.
the class RangeTest method testContainsRange.
@Test
public void testContainsRange() {
Range<Token> one = new Range<Token>(new BigIntegerToken("2"), new BigIntegerToken("10"));
Range<Token> two = new Range<Token>(new BigIntegerToken("2"), new BigIntegerToken("5"));
Range<Token> thr = new Range<Token>(new BigIntegerToken("5"), new BigIntegerToken("10"));
Range<Token> fou = new Range<Token>(new BigIntegerToken("10"), new BigIntegerToken("12"));
assert one.contains(two);
assert one.contains(thr);
assert !one.contains(fou);
assert !two.contains(one);
assert !two.contains(thr);
assert !two.contains(fou);
assert !thr.contains(one);
assert !thr.contains(two);
assert !thr.contains(fou);
assert !fou.contains(one);
assert !fou.contains(two);
assert !fou.contains(thr);
}
use of org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken in project cassandra by apache.
the class RangeTest method testIntersectsWrapping.
@Test
public void testIntersectsWrapping() {
Range<Token> onewrap = new Range<Token>(new BigIntegerToken("10"), new BigIntegerToken("2"));
Range<Token> onecomplement = new Range<Token>(onewrap.right, onewrap.left);
Range<Token> onestartswith = new Range<Token>(onewrap.left, new BigIntegerToken("12"));
Range<Token> oneendswith = new Range<Token>(new BigIntegerToken("1"), onewrap.right);
Range<Token> twowrap = new Range<Token>(new BigIntegerToken("5"), new BigIntegerToken("3"));
Range<Token> not = new Range<Token>(new BigIntegerToken("2"), new BigIntegerToken("6"));
assert !onewrap.intersects(onecomplement);
assert onewrap.intersects(onestartswith);
assert onewrap.intersects(oneendswith);
assert onewrap.intersects(twowrap);
assert twowrap.intersects(onewrap);
assert !onewrap.intersects(not);
assert !not.intersects(onewrap);
assert twowrap.intersects(not);
assert not.intersects(twowrap);
}
Aggregations