Search in sources :

Example 21 with BigIntegerToken

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);
}
Also used : BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) Test(org.junit.Test)

Example 22 with BigIntegerToken

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);
}
Also used : BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) Test(org.junit.Test)

Example 23 with BigIntegerToken

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"));
}
Also used : BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) Test(org.junit.Test)

Example 24 with BigIntegerToken

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);
}
Also used : BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) Test(org.junit.Test)

Example 25 with BigIntegerToken

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);
}
Also used : BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) BigIntegerToken(org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken) Test(org.junit.Test)

Aggregations

BigIntegerToken (org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken)31 Test (org.junit.Test)24 Token (org.apache.cassandra.dht.Token)12 InetAddress (java.net.InetAddress)11 BytesToken (org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken)11 Set (java.util.Set)6 Range (org.apache.cassandra.dht.Range)5 VersionedValue (org.apache.cassandra.gms.VersionedValue)4 TokenMetadata (org.apache.cassandra.locator.TokenMetadata)4 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 ArrayList (java.util.ArrayList)2 IPartitioner (org.apache.cassandra.dht.IPartitioner)2 StringToken (org.apache.cassandra.dht.OrderPreservingPartitioner.StringToken)2 AbstractReplicationStrategy (org.apache.cassandra.locator.AbstractReplicationStrategy)2