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

Examples of com.basho.riak.client.core.query.RiakObject


        String keyPrefix = "mr_test_";
        Namespace ns = new Namespace(bucketType, mrBucketName);
        for (int i = 0; i < 200; i++)
        {
            Location loc = new Location(ns, keyPrefix + i);
            RiakObject ro = new RiakObject().setContentType("text/plain")
                .setValue(BinaryValue.create(Integer.toString(i)));
            // Single index key used on all 200 objects
            ro.getIndexes().getIndex(LongIntIndex.named("user_id")).add(1L);
            StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
            RiakFuture<StoreValue.Response, Location> future = client.executeAsync(sv);
            future.await();
            assertTrue(future.isSuccess());
        }
View Full Code Here


        }
    }

    private void initValues(String bucketType) throws ExecutionException, InterruptedException
    {
        RiakObject obj = new RiakObject();

    obj.setValue(BinaryValue.create("Alice was beginning to get very tired of sitting by her sister on the " +
        "bank, and of having nothing to do: once or twice she had peeped into the " +
        "book her sister was reading, but it had no pictures or conversations in " +
        "it, 'and what is the use of a book,' thought Alice 'without pictures or " +
        "conversation?'"));
        Namespace ns = new Namespace(bucketType, mrBucket);
    Location location = new Location(ns, "p1");
    client.execute(new StoreValue.Builder(obj).withLocation(location).build());

    obj.setValue(BinaryValue.create("So she was considering in her own mind (as well as she could, for the " +
        "hot day made her feel very sleepy and stupid), whether the pleasure " +
        "of making a daisy-chain would be worth the trouble of getting up and " +
        "picking the daisies, when suddenly a White Rabbit with pink eyes ran " +
        "close by her."));

    location = new Location(ns, "p2");
    client.execute(new StoreValue.Builder(obj).withLocation(location).build());


    obj.setValue(BinaryValue.create("The rabbit-hole went straight on like a tunnel for some way, and then " +
        "dipped suddenly down, so suddenly that Alice had not a moment to think " +
        "about stopping herself before she found herself falling down a very deep " +
        "well."));
    location = new Location(ns, "p3");
    client.execute(new StoreValue.Builder(obj).withLocation(location).build());
View Full Code Here

            String key = keyPrefix + i;
            String value = valuePrefix + i;
            Location loc = new Location(ns, key);
            locations.add(loc);
            values.add(BinaryValue.create(value));
            RiakObject o = new RiakObject().setValue(BinaryValue.create(value));
           
            StoreValue sv = new StoreValue.Builder(o).withLocation(loc).build();
            client.execute(sv);
        }
       
View Full Code Here

    }
   
    private void prepSearch(BinaryValue searchBucketType, BinaryValue searchBucket) throws InterruptedException, ExecutionException
    {

        RiakObject obj = new RiakObject().setContentType("application/json");
                           
        obj.setValue(BinaryValue.create("{ \"content_s\":\"Alice was beginning to get very tired of sitting by her sister on the " +
                    "bank, and of having nothing to do: once or twice she had peeped into the " +
                    "book her sister was reading, but it had no pictures or conversations in " +
                    "it, 'and what is the use of a book,' thought Alice 'without pictures or " +
                    "conversation?'\"}"));

        Namespace namespace = new Namespace(searchBucketType, searchBucket);
        Location location = new Location(namespace, BinaryValue.unsafeCreate("p1".getBytes()));
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        obj.setValue(BinaryValue.create("{ \"content_s\":\"So she was considering in her own mind (as well as she could, for the " +
                    "hot day made her feel very sleepy and stupid), whether the pleasure " +
                    "of making a daisy-chain would be worth the trouble of getting up and " +
                    "picking the daisies, when suddenly a White Rabbit with pink eyes ran " +
                    "close by her.\", \"multi_ss\":[\"this\",\"that\"]}"));
       
       
        location = new Location(namespace, BinaryValue.unsafeCreate("p2".getBytes()));
        storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        obj.setValue(BinaryValue.create("{ \"content_s\":\"The rabbit-hole went straight on like a tunnel for some way, and then " +
                    "dipped suddenly down, so suddenly that Alice had not a moment to think " +
                    "about stopping herself before she found herself falling down a very deep " +
                    "well.\"}"));
       
        location = new Location(namespace, BinaryValue.unsafeCreate("p3".getBytes()));
View Full Code Here

        String value = "value";
        Namespace ns = new Namespace(bucketType, bucketName.toString());
       
        for (long i = 0; i < 100; i++)
        {
            RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));

            obj.getIndexes().getIndex(LongIntIndex.named(indexName)).add(5L);
            Location location = new Location(ns, BinaryValue.unsafeCreate((keyBase + i).getBytes()));
            StoreOperation storeOp =
                new StoreOperation.Builder(location)
                    .withContent(obj)
                    .build();
View Full Code Here

        String value = "value";
        Namespace ns = new Namespace(bucketType, bucketName.toString());
       
        for (long i = 0; i < 20; i++)
        {
            RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));

            obj.getIndexes().getIndex(StringBinIndex.named(indexName)).add("foo" + String.format("%02d", i));

           
            Location location = new Location(ns, BinaryValue.unsafeCreate(Long.toString(i).getBytes()));
            StoreOperation storeOp =
                    new StoreOperation.Builder(location)
View Full Code Here

    private void setupIndexTestData(Namespace ns, String indexName, String keyBase, String value)
            throws InterruptedException, ExecutionException
    {
        for (long i = 0; i < 100; i++)
        {
            RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));

            obj.getIndexes().getIndex(LongIntIndex.named(indexName)).add(i);

            Location location = new Location(ns, keyBase + i);
            StoreOperation storeOp =
                    new StoreOperation.Builder(location)
                            .withContent(obj)
View Full Code Here

    private void testDeleteObject(String bucketType) throws InterruptedException, ExecutionException
    {
        final BinaryValue key = BinaryValue.unsafeCreate("my_key".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.unsafeCreate(value.getBytes()));
       
        Location location = new Location(new Namespace(bucketType, bucketName.toString()), key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
               
       
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        RiakObject rObj2 = response.getObjectList().get(0);
       
        assertEquals(rObj.getValue(), rObj2.getValue());
       
        DeleteOperation delOp =
            new DeleteOperation.Builder(location)
                .withVclock(rObj2.getVClock()).build();
        cluster.execute(delOp);
        delOp.get();
       
        fetchOp =
            new FetchOperation.Builder(location).build();
View Full Code Here

    private void testFetchOpNoSiblings(String bucketType) throws InterruptedException, ExecutionException
    {
        final BinaryValue key = BinaryValue.unsafeCreate("my_key_2".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location location = new Location(ns, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
       
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        assertFalse(response.isNotFound());
        List<RiakObject> objectList = response.getObjectList();
        assertEquals(1, objectList.size());
        RiakObject ro = objectList.get(0);
        assertEquals(ro.getValue().toString(), value);
       
    }
View Full Code Here

                .withAllowMulti(true)
                .build();
        cluster.execute(op);
        op.get();
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Location location = new Location(namespace, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
               
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        assertTrue(response.getObjectList().size() > 1);
       
        RiakObject ro = response.getObjectList().get(0);
        assertEquals(ro.getValue().toString(), value);
       
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.RiakObject

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.