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

Examples of com.basho.riak.client.core.query.crdt.ops.MapOp$MapUpdate


    }

    @Override
    public MapOp getOp()
    {
        return new MapOp(removes, updates);
    }
View Full Code Here


        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))
            .update(registerKey, new RegisterOp(registerValue))
            .update(mapKey, new MapOp());

        DtUpdateOperation.Builder operation = new DtUpdateOperation.Builder(namespace);
        RiakDtPB.MapOp mapOp = operation.getMapOp(op);

        assertTrue(mapOp.getUpdatesCount() == 5);
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);

        assertTrue(mapOp.getUpdatesCount() == 1);
View Full Code Here

        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();

        cluster.execute(update);
        update.get();

        map = fetchMap(mapBucketType, bucketName, key);
        assertEquals(1, map.view().size());
      assertNotNull(map.view().get(mapKey));
      assertEquals(1, map.view().get(mapKey).size());
        assertTrue(map.view().get(mapKey).get(0).isSet());
        RiakSet set = map.view().get(mapKey).get(0).getAsSet();
        assertTrue(set.view().contains(setValue));


        mapKey = BinaryValue.create("counter");
       
        update = new DtUpdateOperation.Builder(location)
            .withOp(new MapOp().update(mapKey, new CounterOp(1)))
            .build();

        cluster.execute(update);
        update.get();

        map = fetchMap(mapBucketType, bucketName, key);
        assertEquals(2, map.view().size());
      assertNotNull(map.view().get(mapKey));
      assertEquals(1, map.view().get(mapKey).size());
        assertTrue(map.view().get(mapKey).get(0).isCounter());
        RiakCounter counter = map.view().get(mapKey).get(0).getAsCounter();
        assertEquals((Long) 1L, counter.view());


        mapKey = BinaryValue.create("flag");

        update =
            new DtUpdateOperation.Builder(location)
                .withOp(new MapOp().update(mapKey, new FlagOp(true)))
                .build();

        cluster.execute(update);
        update.get();

        map = fetchMap(mapBucketType, bucketName, key);
        assertEquals(3, map.view().size());
      assertNotNull(map.view().get(mapKey));
      assertEquals(1, map.view().get(mapKey).size());
        assertTrue(map.view().get(mapKey).get(0).isFlag());
        RiakFlag flag = map.view().get(mapKey).get(0).getAsFlag();
        assertTrue(flag.getEnabled());


        mapKey = BinaryValue.create("register");
       
        update = new DtUpdateOperation.Builder(location)
            .withOp(new MapOp().update(mapKey, new RegisterOp(mapKey)))
            .build();

        cluster.execute(update);
        update.get();

        map = fetchMap(mapBucketType, bucketName, key);
        assertEquals(4, map.view().size());
      assertNotNull(map.view().get(mapKey));
      assertEquals(1, map.view().get(mapKey).size());
        RiakRegister register = map.view().get(mapKey).get(0).getAsRegister();
        assertEquals(mapKey, register.getValue());


        mapKey = BinaryValue.create("map");

        update = new DtUpdateOperation.Builder(location)
            .withOp(new MapOp().update(mapKey, new MapOp().update(mapKey, new FlagOp(false))))
            .build();

        cluster.execute(update);
        update.get();
View Full Code Here

        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();
       
        ByteBuffer nowBinary = ByteBuffer.allocate(8).putLong(System.currentTimeMillis());
        byte[] now = nowBinary.array();
       
        CounterOp counterOp = new CounterOp(1);
        RegisterOp registerOp = new RegisterOp(BinaryValue.create(now));
        FlagOp flagOp = new FlagOp(false);
        SetOp setOp = new SetOp()
                        .add(BinaryValue.create("Item 1"))
                        .add(BinaryValue.create("Item 2"));
       
        innerMap.update(logins, counterOp)
                .update(lastLogin, registerOp)
                .update(loggedIn, flagOp)
                .update(cartContents, setOp);
       
        outerMap.update(username, innerMap);
View Full Code Here

        SetOp setOp = new SetOp()
                        .add(BinaryValue.create("Item 1"))
                        .add(BinaryValue.create("Item 2"));
       
       
        MapOp op = new MapOp().update(mapKey, setOp);
       
        DtUpdateOperation update = new DtUpdateOperation.Builder(loc)
                                        .withOp(op)
                                        .withReturnBody(true)
                                        .build();
View Full Code Here

     * @return the update used by the client core.
     */
    @Override
    public MapOp getOp()
    {
        return new MapOp(removes, updates);
    }
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.crdt.ops.MapOp$MapUpdate

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.