Package com.basho.riak.client.core.query.indexes

Examples of com.basho.riak.client.core.query.indexes.RawIndex


        assertTrue(indexes.hasIndex(new LongIntIndex.Name("my_index")));
       
        LongIntIndex lii = indexes.getIndex(new LongIntIndex.Name("my_index"));
        assertTrue(lii.hasValue(4L));
       
        RawIndex rri = indexes.getIndex(new RawIndex.Name("my_index", IndexType.INT));
        assertTrue(rri.hasValue(BinaryValue.unsafeCreate(String.valueOf(4L).getBytes())));
       
        assertEquals(indexes.size(), 1);
       
    }
View Full Code Here


    }
   
    @Test
    public void wrapping()
    {
        RawIndex index = indexes.getIndex(new RawIndex.Name("foo", IndexType.BIN));
        BinaryValue baw = BinaryValue.unsafeCreate("value".getBytes());
        index.add(baw);
       
        StringBinIndex wrapper = indexes.getIndex(new StringBinIndex.Name("foo"));
        assertNotSame(index, wrapper);
        assertEquals(index, wrapper);
        assertTrue(wrapper.hasValue("value"));
       
        wrapper.remove("value");
       
        index = indexes.getIndex(new RawIndex.Name("foo", IndexType.BIN));
        assertFalse(index.hasValue(baw));
    }
View Full Code Here

   
    @Test
    public void builderCreatesIndex()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.INT);
        RawIndex index = builder.createIndex();
        assertEquals(index.getName(), "index_name");
        assertEquals(index.getType(), IndexType.INT);
        assertEquals(index.getFullname(), "index_name" + IndexType.INT.suffix());
       
        builder = new RawIndex.Name("index_name", IndexType.BIN);
        index = builder.createIndex();
        assertEquals(index.getName(), "index_name");
        assertEquals(index.getType(), IndexType.BIN);
        assertEquals(index.getFullname(), "index_name" + IndexType.BIN.suffix());
       
    }
View Full Code Here

   
    @Test
    public void stripSuffix()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name_int", IndexType.INT);
        RawIndex index = builder.createIndex();
        assertEquals(index.getName(), "index_name");
    }
View Full Code Here

   
    @Test
    public void addValue()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
        byte[] array = "value".getBytes();
        BinaryValue baw = BinaryValue.unsafeCreate(array);
       
        assertEquals(index.size(), 0);
        index.add(baw);
        assertEquals(index.size(), 1);
        assertTrue(index.hasValue(baw));
    }
View Full Code Here

   
    @Test
    public void addValues()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
       
        List<BinaryValue> values = new LinkedList<BinaryValue>();
        for (int i = 0; i < 5; i++)
        {
            values.add(BinaryValue.unsafeCreate(("value" + i).getBytes()));
        }
       
        index.add(values);
       
        assertEquals(index.size(), 5);
       
        for (BinaryValue baw : values)
        {
            assertTrue(index.hasValue(baw));
        }
    }
View Full Code Here

   
    @Test
    public void removeValue()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
        BinaryValue baw = null;
        for (int i = 0; i < 3; i++)
        {
            baw = BinaryValue.unsafeCreate(("value" + i).getBytes());
            index.add(baw);
        }
       
        assertEquals(index.size(), 3);
        assertTrue(index.hasValue(baw));
        index.remove(baw);
        assertFalse(index.hasValue(baw));
        assertEquals(index.size(), 2);
    }
View Full Code Here

   
    @Test
    public void removeValues()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
       
        List<BinaryValue> values = new LinkedList<BinaryValue>();
        for (int i = 0; i < 5; i++)
        {
            values.add(BinaryValue.unsafeCreate(("value" + i).getBytes()));
        }
       
        index.add(values);
       
        assertEquals(index.size(), 5);
        BinaryValue baw = values.remove(0);
        index.remove(values);
        assertEquals(index.size(), 1);
        assertTrue(index.hasValue(baw));
        for (BinaryValue b : values )
        {
            assertFalse(index.hasValue(b));
        }
    }
View Full Code Here

   
    @Test
    public void noDuplicates()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
       
        for (int i = 0; i < 5; i++)
        {
            index.add(BinaryValue.unsafeCreate("value".getBytes()));
        }
       
        assertEquals(index.size(), 1);
       
    }
View Full Code Here

   
    @Test
    public void wrap()
    {
        RawIndex.Name builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index = builder.createIndex();
       
        List<BinaryValue> values = new LinkedList<BinaryValue>();
        for (int i = 0; i < 5; i++)
        {
            values.add(BinaryValue.unsafeCreate(("value" + i).getBytes()));
        }
       
        index.add(values);
       
        builder = new RawIndex.Name("index_name", IndexType.BIN);
        RawIndex index2 = builder.wrap(index).createIndex();
       
        assertEquals(index, index2);
        assertNotSame(index, index2);
        assertTrue(index2.hasValue(values.get(0)));
        index.remove(values.get(0));
        assertFalse(index2.hasValue(values.get(0)));
       
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.indexes.RawIndex

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.