Package com.basho.riak.client.core.util

Examples of com.basho.riak.client.core.util.BinaryValue


    @Test
    public void testGetMapOpUpdates()
    {

        BinaryValue counterKey = BinaryValue.create("counter");
        BinaryValue setKey = BinaryValue.create("set");
        BinaryValue flagKey = BinaryValue.create("flag");
        BinaryValue registerKey = BinaryValue.create("register");
        BinaryValue mapKey = BinaryValue.create("map");

        BinaryValue setAddValue = BinaryValue.create("1");

        BinaryValue registerValue = BinaryValue.create("value");

        BinaryValue mapAddValue = BinaryValue.create("value");

        MapOp op = new MapOp()
            .update(counterKey, new CounterOp(1))
            .update(setKey, new SetOp().add(setAddValue))
            .update(flagKey, new FlagOp(true))
View Full Code Here


        final long counterValue = 1;

        final boolean flagValue = true;

        BinaryValue registerValue = BinaryValue.create("stuff");

        BinaryValue counterKey = BinaryValue.create("1");
        BinaryValue setKey = BinaryValue.create("2");
        BinaryValue mapKey = BinaryValue.create("3");
        BinaryValue registerKey = BinaryValue.create("4");
        BinaryValue flagKey = BinaryValue.create("5");

        RiakDtPB.DtUpdateResp resp = RiakDtPB.DtUpdateResp.newBuilder()
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setType(RiakDtPB.MapField.MapFieldType.COUNTER)
                    .setName(ByteString.copyFrom(counterKey.unsafeGetValue())))
                .setCounterValue(counterValue))
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setName(ByteString.copyFrom(setKey.unsafeGetValue()))
                    .setType(RiakDtPB.MapField.MapFieldType.SET))
                .addAllSetValue(setValues))
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setName(ByteString.copyFrom(mapKey.unsafeGetValue()))
                    .setType(RiakDtPB.MapField.MapFieldType.MAP)))
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setName(ByteString.copyFrom(registerKey.unsafeGetValue()))
                    .setType(RiakDtPB.MapField.MapFieldType.REGISTER))
                .setRegisterValue(ByteString.copyFrom(registerValue.unsafeGetValue())))
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setName(ByteString.copyFrom(flagKey.unsafeGetValue()))
                    .setType(RiakDtPB.MapField.MapFieldType.FLAG))
                .setFlagValue(flagValue))
            .build();

        CrdtResponseConverter converter = new CrdtResponseConverter();
View Full Code Here

    @Test
    public void testGetMapOpUpdateNestedMaps()
    {

        BinaryValue key1 = BinaryValue.create("key1");
        MapOp op1 = new MapOp().update(key1, new CounterOp(1));

        BinaryValue key2 = BinaryValue.create("key2");
        MapOp op2 = new MapOp().update(key2, op1);

        BinaryValue key3 = BinaryValue.create("key3");
        MapOp op3 = new MapOp().update(key3, op2);

        DtUpdateOperation.Builder operation = new DtUpdateOperation.Builder(namespace);
        RiakDtPB.MapOp mapOp = operation.getMapOp(op3);
View Full Code Here

    }

    @Test
    public void testDtUpdateRespNestedMap()
    {
        BinaryValue mapKey = BinaryValue.create("key");

        RiakDtPB.DtUpdateResp resp = RiakDtPB.DtUpdateResp.newBuilder()
            .addMapValue(RiakDtPB.MapEntry.newBuilder()
                .setField(RiakDtPB.MapField.newBuilder()
                    .setName(ByteString.copyFrom(mapKey.unsafeGetValue()))
                    .setType(RiakDtPB.MapField.MapFieldType.MAP))
                .addMapValue(RiakDtPB.MapEntry.newBuilder()
                    .setField(RiakDtPB.MapField.newBuilder()
                        .setName(ByteString.copyFrom(mapKey.unsafeGetValue()))
                        .setType(RiakDtPB.MapField.MapFieldType.MAP))
                    .addMapValue(RiakDtPB.MapEntry.newBuilder()
                        .setField(RiakDtPB.MapField.newBuilder()
                            .setName(ByteString.copyFrom(mapKey.unsafeGetValue()))
                            .setType(RiakDtPB.MapField.MapFieldType.MAP)))))
            .build();

        CrdtResponseConverter converter = new CrdtResponseConverter();
View Full Code Here

        assumeTrue(testCrdt);

        final long iterations = 1;

        BinaryValue key = BinaryValue.create("key");

        resetAndEmptyBucket(new Namespace(counterBucketType, bucketName));

        RiakCounter counter = fetchCounter(counterBucketType, bucketName, key);
        assertEquals((Long) 0L, counter.view());
View Full Code Here

        assumeTrue(testCrdt);

        final int iterations = 1;

        BinaryValue key = BinaryValue.create("key");

        resetAndEmptyBucket(new Namespace(setBucketType, bucketName));

        RiakSet set = fetchSet(setBucketType, bucketName, key);
        assertTrue(set.view().isEmpty());

        Set<BinaryValue> testValues = new HashSet<BinaryValue>(iterations);
        Location location = new Location(new Namespace(setBucketType, bucketName), key);
        BinaryValue ctx = null;
        for (int i = 0; i < iterations; ++i)
        {
            ByteBuffer buff = (ByteBuffer) ByteBuffer.allocate(8).putInt(i).rewind();
            BinaryValue wrapped = BinaryValue.create(buff.array());
            testValues.add(wrapped);

            DtUpdateOperation update =
                new DtUpdateOperation.Builder(location)
                    .withOp(new SetOp().add(wrapped))
View Full Code Here

        assumeTrue(testCrdt);

        final int iterations = 1;

        BinaryValue key = BinaryValue.create("key");

        resetAndEmptyBucket(new Namespace(setBucketType, bucketName));

        RiakSet set = fetchSet(setBucketType, bucketName, key);
        assertTrue(set.view().isEmpty());

        Set<BinaryValue> testValues = new HashSet<BinaryValue>(iterations);
        Location location = new Location(new Namespace(setBucketType, bucketName), key);
        for (int i = 0; i < iterations; ++i)
        {
            ByteBuffer buff = (ByteBuffer) ByteBuffer.allocate(8).putInt(i).rewind();
            BinaryValue wrapped = BinaryValue.create(buff.array());
            testValues.add(wrapped);

            DtUpdateOperation add =
                new DtUpdateOperation.Builder(location)
                    .withOp(new SetOp().add(wrapped))
View Full Code Here

    public void testCrdtMap() throws ExecutionException, InterruptedException
    {

        assumeTrue(testCrdt);

        BinaryValue key = BinaryValue.create("key");

        resetAndEmptyBucket(new Namespace(mapBucketType, bucketName));

        RiakMap map = fetchMap(mapBucketType, bucketName, key);

        assertTrue(map.view().isEmpty());

        Location location = new Location(new Namespace(mapBucketType, bucketName), key);
        BinaryValue setValue = BinaryValue.create("value");
        BinaryValue mapKey = BinaryValue.create("set");
       
        DtUpdateOperation update =
            new DtUpdateOperation.Builder(location)
                .withOp(new MapOp().update(mapKey, new SetOp().add(setValue)))
                .build();
View Full Code Here

                  -> "logged-in"  : flag
                  -> "cart"       : set

         */
       
        BinaryValue key = BinaryValue.create("user-info2");
        BinaryValue username = BinaryValue.create("Bob");
        BinaryValue logins = BinaryValue.create("logins");
        BinaryValue lastLogin = BinaryValue.create("last-login");
        BinaryValue loggedIn = BinaryValue.create("logged-in");
        BinaryValue cartContents = BinaryValue.create("cart");
       
       
        MapOp outerMap = new MapOp();
        MapOp innerMap = new MapOp();
       
View Full Code Here

    @Test
    public void testSimpleMap() throws InterruptedException, ExecutionException
    {
        assumeTrue(testCrdt);
       
        BinaryValue key = BinaryValue.create("simple-map");
        BinaryValue mapKey = BinaryValue.create("set");
        Namespace ns = new Namespace(mapBucketType, bucketName);
        Location loc = new Location(ns, key);
       
        SetOp setOp = new SetOp()
                        .add(BinaryValue.create("Item 1"))
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.util.BinaryValue

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.