Examples of RiakSet


Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

                if (coreResponse.hasContext())
                {
                    context = new Context(coreResponse.getContext());
                }

                RiakSet datatype = extractDatatype(element);

                return new Response(datatype, context);
            }

            @Override
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

            new CoreFutureAdapter<Response, Location, DtUpdateOperation.Response, Location>(coreFuture)
            {
                @Override
                protected Response convertResponse(DtUpdateOperation.Response coreResponse)
                {
                    RiakSet set = null;
                    if (coreResponse.hasCrdtElement())
                    {
                        RiakDatatype element = coreResponse.getCrdtElement();
                        set = element.getAsSet();
                    }
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

    // logged-in - flag
    RiakFlag loggedInFlag = usernameMap.getFlag(loggedIn);
    assertEquals((Boolean) true, loggedInFlag.view());

    // cart - asSet
    RiakSet shoppingCartSet = usernameMap.getSet(shoppingCart);
    Set<BinaryValue> setView = shoppingCartSet.view();
    Set<BinaryValue> expectedSet = new HashSet<BinaryValue>();
    for (int i = 0; i < 10; ++i)
    {
      ByteBuffer b = ByteBuffer.allocate(4);
      b.putInt(i);
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

        assertTrue(crdtMap.get(flagKey).get(0).isFlag());

        RiakCounter riakCounter = crdtMap.get(counterKey).get(0).getAsCounter();
        assertEquals((Long) counterValue, riakCounter.view());

        RiakSet crdtSet = crdtMap.get(setKey).get(0).getAsSet();
        assertEquals(wrappedSetValues, crdtSet.view());

        // the asMap doesn't have any values

        RiakRegister crdtRegister = crdtMap.get(registerKey).get(0).getAsRegister();
        assertEquals(registerValue, crdtRegister.getValue());
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

        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))
                    .withReturnBody(true)
                    .build();

            cluster.execute(update);
            DtUpdateOperation.Response resp = update.get();
            ctx = resp.getContext();
            set = resp.getCrdtElement().getAsSet();
        }

        assertEquals(iterations, set.view().size());
        assertEquals(testValues, set.view());

       
        for (BinaryValue setElement : testValues)
        {

            DtUpdateOperation update =
                new DtUpdateOperation.Builder(location)
                    .withOp(new SetOp().remove(setElement))
                    .withContext(ctx)
                    .build();

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

        }

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

        resetAndEmptyBucket(new Namespace(setBucketType, bucketName));

    }
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

        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))
                    .withReturnBody(true)
                    .build();

            cluster.execute(add);
            DtUpdateOperation.Response resp = add.get();

            DtUpdateOperation delete =
                new DtUpdateOperation.Builder(location)
                    .withOp(new SetOp().remove(wrapped))
                    .withContext(resp.getContext())
                    .build();

            cluster.execute(delete);
            delete.get();
        }

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

        resetAndEmptyBucket(new Namespace(setBucketType, bucketName));

    }
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

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

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

        assertNotNull(counter);
        RiakRegister register = map.getRegister(lastLogin);
        assertNotNull(register);
        RiakFlag flag = map.getFlag(loggedIn);
        assertNotNull(flag);
        RiakSet set = map.getSet(cartContents);
        assertNotNull(set);
       
        resetAndEmptyBucket(new Namespace(mapBucketType, bucketName));
       
    }
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

                if (coreResponse.hasContext())
                {
                    context = new Context(coreResponse.getContext());
                }

                RiakSet datatype = extractDatatype(element);

                return new Response(datatype, context);
            }

            @Override
View Full Code Here

Examples of com.basho.riak.client.core.query.crdt.types.RiakSet

            new CoreFutureAdapter<Response, Location, DtUpdateOperation.Response, Location>(coreFuture)
            {
                @Override
                protected Response convertResponse(DtUpdateOperation.Response coreResponse)
                {
                    RiakSet set = null;
                    if (coreResponse.hasCrdtElement())
                    {
                        RiakDatatype element = coreResponse.getCrdtElement();
                        set = element.getAsSet();
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.