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

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


   
    @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

   
    @Test
    public void copy()
    {
        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.copyFrom(index).createIndex();
       
        assertEquals(index, index2);
        assertNotSame(index, index2);
        assertTrue(index2.hasValue(values.get(0)));
        index.remove(values.get(0));
        assertTrue(index2.hasValue(values.get(0)));
    }
View Full Code Here

   
    @Test
    public void iterator()
    {
        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);
       
        for (BinaryValue b : index)
        {
            assertTrue(index.hasValue(b));
        }
       
        Iterator<BinaryValue> i = index.iterator();
       
        while (i.hasNext())
        {
            BinaryValue b = i.next();
            i.remove();
            assertFalse(index.hasValue(b));
        }
    }
View Full Code Here

TOP

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

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.