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

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


        testBasicMR(new Namespace(bucketType, bucketName));
    }
   
    private void testBasicMR(Namespace namespace) throws InterruptedException, ExecutionException, IOException
    {
        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?'"));
        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("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(namespace, BinaryValue.unsafeCreate("p2".getBytes()));
        storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        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(namespace, BinaryValue.unsafeCreate("p3".getBytes()));
        storeOp =
View Full Code Here


    {
        final Namespace ns = new Namespace(bucketType, bucketName.toString() + "_2");
        final BinaryValue key = BinaryValue.unsafeCreate("my_key".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Location location = new Location(ns, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
View Full Code Here

       
        for (int i = 0; i < 1000; i++)
        {
            semaphore.acquire();
            BinaryValue key = BinaryValue.unsafeCreate((baseKey + i).getBytes());
            RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
            Location location = new Location(ns, key);
            StoreOperation storeOp =
                new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
View Full Code Here

       
        VClock vclock = AnnotationUtil.getVClock(domainObject);
        String contentType =
            AnnotationUtil.getContentType(domainObject, RiakObject.DEFAULT_CONTENT_TYPE);
       
        RiakObject riakObject = new RiakObject();
       
        AnnotationUtil.getUsermetaData(riakObject.getUserMeta(), domainObject);
        AnnotationUtil.getIndexes(riakObject.getIndexes(), domainObject);
        AnnotationUtil.getLinks(riakObject.getLinks(), domainObject);
       
        ContentAndType cAndT = fromDomain(domainObject);
        contentType = cAndT.contentType != null ? cAndT.contentType : contentType;
       
        riakObject.setContentType(contentType)
                    .setValue(cAndT.content)
                    .setVClock(vclock);
       
        // We allow an annotated object to omit @BucketType and get the default
        Namespace ns;
View Full Code Here

    }
   
    @Override
    public Converter.OrmExtracted fromDomain(String domainObject, Namespace namespace, BinaryValue key)
    {
        RiakObject obj = new RiakObject()
                        .setValue(BinaryValue.create(domainObject))
                        .setContentType("text/plain");
        return new Converter.OrmExtracted(obj, namespace, key);
    }
View Full Code Here

    }
   
    @Override
    protected FutureOperation<?, ?, ?> buildOperation()
    {
        RiakObject ro = new RiakObject().setValue(value);
        StoreOperation op = new StoreOperation.Builder(location).withContent(ro).build();
        return op;
    }
View Full Code Here

        List<RiakObject> roList = new LinkedList<RiakObject>();
        BasicVClock vclock = new BasicVClock(contentVClock.toByteArray());
       
        for (RpbContent content : contentList)
        {
            RiakObject ro = new RiakObject();
           
            ro.setVClock(vclock);
           
            if (content.hasDeleted())
            {
                ro.setDeleted(content.getDeleted());
            }
           
            if (content.hasContentType())
            {
                ro.setContentType(content.getContentType().toStringUtf8());
            }
           
            if (content.hasCharset())
            {
                ro.setCharset(content.getCharset().toStringUtf8());
            }
           
            if (content.hasLastMod())
            {
                int lastMod = content.getLastMod();
                int lastModUsec = content.getLastModUsecs();
                ro.setLastModified((lastMod * 1000L) + (lastModUsec / 1000L));
            }
           
            if (content.hasValue() && !content.getValue().isEmpty())
            {
                ro.setValue(BinaryValue.unsafeCreate(content.getValue().toByteArray()));
            }
           
            if (content.hasVtag())
            {
                ro.setVTag(content.getVtag().toStringUtf8());
            }
           
            if (content.getLinksCount() > 0)
            {
                List<RiakKvPB.RpbLink> pbLinkList = content.getLinksList();
                RiakLinks riakLinks = ro.getLinks();
               
                for (RiakKvPB.RpbLink pbLink : pbLinkList)
                {
                    RiakLink link = new RiakLink(pbLink.getBucket().toStringUtf8(),
                        pbLink.getKey().toStringUtf8(),
                        pbLink.getTag().toStringUtf8());
                    riakLinks.addLink(link);
                }
            }
           
            if (content.getIndexesCount() > 0)
            {
                RiakIndexes indexes = ro.getIndexes();
                for (RiakPB.RpbPair p : content.getIndexesList())
                {
                    String name = p.getKey().toStringUtf8();
                    try
                    {
                        IndexType type = IndexType.typeFromFullname(name);
                        indexes.getIndex(RawIndex.named(name, type))
                            .add(BinaryValue.unsafeCreate(p.getValue().toByteArray()));
                    }
                    catch (IllegalArgumentException e)
                    {
                        logger.error("Unknown index type during conversion: {};{}", name, e);
                    }
                }
            }
           
            if (content.getUsermetaCount() > 0)
            {
                RiakUserMetadata userMeta = ro.getUserMeta();
                for (int j = 0; j < content.getUsermetaCount(); j++)
                {
                    RiakPB.RpbPair pair = content.getUsermeta(j);
                    userMeta.put(BinaryValue.unsafeCreate(pair.getKey().toByteArray()),
                        BinaryValue.unsafeCreate(pair.getValue().toByteArray()));
View Full Code Here

            // To unify the behavior of having just a tombstone vs. siblings
            // that include a tombstone, we create an empty object and mark
            // it deleted
            if (response.getContentCount() == 0)
            {
                RiakObject ro = new RiakObject()
                                    .setDeleted(true)
                                    .setVClock(new BasicVClock(response.getVclock().toByteArray()));
               
                responseBuilder.addObject(ro);
            }
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.