Package org.apache.cassandra.dht

Examples of org.apache.cassandra.dht.Range


        List<TokenRange> ranges = new ArrayList<TokenRange>();
        Token.TokenFactory tf = getPartitioner().getTokenFactory();

        for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
        {
            Range range = entry.getKey();
            List<InetAddress> addresses = entry.getValue();
            List<String> endpoints = new ArrayList<String>(addresses.size());
            List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
            List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());
View Full Code Here


        public TreeRequest deserialize(DataInput dis, int version) throws IOException
        {
            String sessId = dis.readUTF();
            InetAddress endpoint = CompactEndpointSerializationHelper.deserialize(dis);
            CFPair cfpair = new CFPair(dis.readUTF(), dis.readUTF());
            Range range;
            if (version > MessagingService.VERSION_07)
                range = (Range) AbstractBounds.serializer().deserialize(dis);
            else
                range = new Range(StorageService.getPartitioner().getMinimumToken(), StorageService.getPartitioner().getMinimumToken());

            return new TreeRequest(sessId, endpoint, range, cfpair);
        }
View Full Code Here

    protected IPartitioner partitioner;
    protected MerkleTree mt;

    private Range fullRange()
    {
        return new Range(partitioner.getMinimumToken(), partitioner.getMinimumToken());
    }
View Full Code Here

        mt.split(tok(4));
        mt.split(tok(6));
        mt.split(tok(7));

        assertEquals(4, mt.size());
        assertEquals(new Range(tok(7), tok(-1)), mt.get(tok(-1)));
        assertEquals(new Range(tok(-1), tok(4)), mt.get(tok(3)));
        assertEquals(new Range(tok(-1), tok(4)), mt.get(tok(4)));
        assertEquals(new Range(tok(4), tok(6)), mt.get(tok(6)));
        assertEquals(new Range(tok(6), tok(7)), mt.get(tok(7)));

        // check depths
        assertEquals((byte)1, mt.get(tok(4)).depth);
        assertEquals((byte)2, mt.get(tok(6)).depth);
        assertEquals((byte)3, mt.get(tok(7)).depth);
View Full Code Here

        assertEquals(3, mt.size());
       
        // should fail to split below hashdepth
        assertFalse(mt.split(tok(1)));
        assertEquals(3, mt.size());
        assertEquals(new Range(tok(4), tok(-1)), mt.get(tok(-1)));
        assertEquals(new Range(tok(-1), tok(2)), mt.get(tok(2)));
        assertEquals(new Range(tok(2), tok(4)), mt.get(tok(4)));
    }
View Full Code Here

        assertEquals(2, mt.size());
       
        // should fail to split above maxsize
        assertFalse(mt.split(tok(2)));
        assertEquals(2, mt.size());
        assertEquals(new Range(tok(4), tok(-1)), mt.get(tok(-1)));
        assertEquals(new Range(tok(-1), tok(4)), mt.get(tok(4)));
    }
View Full Code Here

    {
        Iterator<TreeRange> ranges;
       
        // (zero, zero]
        ranges = mt.invalids();
        assertEquals(new Range(tok(-1), tok(-1)), ranges.next());
        assertFalse(ranges.hasNext());

        // all invalid
        mt.split(tok(4));
        mt.split(tok(2));
        mt.split(tok(6));
        mt.split(tok(3));
        mt.split(tok(5));
        ranges = mt.invalids();
        assertEquals(new Range(tok(6), tok(-1)), ranges.next());
        assertEquals(new Range(tok(-1), tok(2)), ranges.next());
        assertEquals(new Range(tok(2), tok(3)), ranges.next());
        assertEquals(new Range(tok(3), tok(4)), ranges.next());
        assertEquals(new Range(tok(4), tok(5)), ranges.next());
        assertEquals(new Range(tok(5), tok(6)), ranges.next());
        assertEquals(new Range(tok(6), tok(-1)), ranges.next());
        assertFalse(ranges.hasNext());
    }
View Full Code Here

    @Test
    public void testHashFull()
    {
        byte[] val = DUMMY;
        Range range = new Range(tok(-1), tok(-1));

        // (zero, zero]
        assertNull(mt.hash(range));
       
        // validate the range
View Full Code Here

    public void testHashPartial()
    {
        byte[] val = DUMMY;
        byte[] leftval = hashed(val, 1, 1);
        byte[] partialval = hashed(val, 1);
        Range left = new Range(tok(-1), tok(4));
        Range partial = new Range(tok(2), tok(4));
        Range right = new Range(tok(4), tok(-1));
        Range linvalid = new Range(tok(1), tok(4));
        Range rinvalid = new Range(tok(4), tok(6));

        // (zero,two] (two,four] (four, zero]
        mt.split(tok(4));
        mt.split(tok(2));
        assertNull(mt.hash(left));
View Full Code Here

    {
        byte[] val = DUMMY;
        byte[] lchildval = hashed(val, 3, 3, 2);
        byte[] rchildval = hashed(val, 2, 2);
        byte[] fullval = hashed(val, 3, 3, 2, 2, 2);
        Range full = new Range(tok(-1), tok(-1));
        Range lchild = new Range(tok(-1), tok(4));
        Range rchild = new Range(tok(4), tok(-1));
        Range invalid = new Range(tok(1), tok(-1));

        // (zero,one] (one, two] (two,four] (four, six] (six, zero]
        mt.split(tok(4));
        mt.split(tok(2));
        mt.split(tok(6));
View Full Code Here

TOP

Related Classes of org.apache.cassandra.dht.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.