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

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


    @Test
    public void updateRiakObject() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key9");
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(new Update<RiakObject>(){

                                        @Override
                                        public RiakObject apply(RiakObject original)
View Full Code Here


    @Test
    public void simpleTest() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_store_key");
        Pojo pojo = new Pojo();
        pojo.value = "test store value";
        StoreValue sv =
            new StoreValue.Builder(pojo).withLocation(loc)
                .withOption(Option.RETURN_BODY, true)
View Full Code Here

        client.execute(sbp);
       
        RiakObject ro = new RiakObject()
                        .setContentType("application/json")
                        .setValue(BinaryValue.create("{\"name_s\":\"Lion-o\", \"age_i\":30, \"leader_b\":true}"));
        Location location = new Location(ns, "liono");
        StoreValue sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Cheetara\", \"age_i\":28, \"leader_b\":false}"));
        location = new Location(ns, "cheetara");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Snarf\", \"age_i\":43}"));
        location = new Location(ns, "snarf");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        ro = new RiakObject()
                .setContentType("application/json")
                .setValue(BinaryValue.create("{\"name_s\":\"Panthro\", \"age_i\":36}"));
        location = new Location(ns, "panthro");
        sv = new StoreValue.Builder(ro).withLocation(location).build();
        client.execute(sv);
       
        // Sleep some more or ... yeah, it doesn't work.
        Thread.sleep(3000);
View Full Code Here

    {
        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)));
            ro.getIndexes().getIndex(LongIntIndex.named("user_id")).add((long)i);
            StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
            RiakFuture<StoreValue.Response, Location> future = client.executeAsync(sv);
View Full Code Here

    {
        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();
View Full Code Here

        "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

  {
    initValues(bucketType);
       
        Namespace ns = new Namespace(bucketType, mrBucket);
    MapReduce mr = new BucketKeyMapReduce.Builder()
        .withLocation(new Location(ns, "p1"))
        .withLocation(new Location(ns, "p2"))
        .withLocation(new Location(ns, "p3"))
        .withMapPhase(Function.newAnonymousJsFunction(
            "function(v, key_data) {" +
                "  var m = v.values[0].data.toLowerCase().match(/\\w*/g);" +
                "  var r = [];" +
                "  for(var i in m) {" +
View Full Code Here

    {
        initValues(bucketType);
        Namespace ns = new Namespace(bucketType, mrBucket);
       
        MapReduce mr = new BucketKeyMapReduce.Builder()
        .withLocation(new Location(ns, "p1"))
        .withLocation(new Location(ns, "p2"))
        .withLocation(new Location(ns, "p3"))
                .withMapPhase(Function.newErlangFunction("riak_kv_mapreduce", "map_object_value"), false)
                .withReducePhase(Function.newErlangFunction("riak_kv_mapreduce","reduce_sort"), true)
                .build();
       
        MapReduce.Response response = client.execute(mr);
View Full Code Here

        // Store some stuff
        for (int i = 0; i < 5; i++)
        {
            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();
View Full Code Here

                    "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()));
        storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .build();
       
View Full Code Here

TOP

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

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.