Re: Multiple named counters per key

2013-11-08 Thread Dave Rusek
Could you accomplish this with a bucket which is a map of counters? The counter 
name would be the map key.

-- 
Dave Rusek
Sent with Airmail

On November 8, 2013 at 12:50:23 PM, Mark A. Basil, Jr. (m...@badarmadillo.com) 
wrote:

Just a thought.  It would be handy if one could add many named counters per 
buket/key to more closely handle a shopping cart scenario.  Otherwise, unless 
I’m mistaken, one would have to have a bucket that would be the “cart” and keys 
which are the “items”.  That doesn’t make a lot of sense to me.

 

___  
riak-users mailing list  
riak-users@lists.basho.com  
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com  
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


Re: Riak Java client counter object

2014-01-24 Thread Dave Rusek
Guido,

I’m sorry, there are not currently any docs available. Rest assured they are a 
work in progress. In the meantime, please feel free to check-out the current 
pre-release [1]. The pre-release covers the low level API we have built on top 
of the PB interface. There is a start to a friendlier API in the develop branch 
of riak-java-client [2].

If you would like to get started with the low level API to begin getting a feel 
for Riak datatypes, I have included a few snippets that will hopefully help. 
The counters (and the data structures in general) are implemented as two 
separate operations: Fetch and Update. Updating a counter that does not exist 
will create it and initialize it to the given value. Fetching a counter that 
has not had a value stored will return an empty value.

While the low level API does not have convenience methods for getAndIncrement 
and the like, they can all be easily accomplished given fetch and update. It 
would clearly be easy for us to provide methods for these typical access 
patterns and in fact, it is something we are planning on doing.

RiakCluster cluster = …
BinaryValue bucket = …
BinaryValue key = …
BinaryValue type = ...

fetch():

DtFetchOperation get = 
new DtFetchOperation.Builder(bucket, key)
.withBucketType(type)
.build();

DtFetchOperation.Response response = cluster.execute(get).get();

long value;
CrdtElement element = response.getCrdtElement();
if (crdtElement.isCounter()) {
value = element.getCounter().getValue();
} else {
... 
}

update():

DtUpdateOperation update = 
new DtUpdateOperation.Builder(bucket, key)
.withBucketType(type)
.withReturnBody(true)
.withOp(new CounterOp(1)) // increment by 1
.build();

DtUpdateOperation.Response response = cluster.execute(update).get();

long value;
CrdtElement element = response.getCrdtElement();
if (crdtElement.isCounter()) {
value = element.getCounter().getValue();
} else {
... 
}

getAndIncrement();

long value = fetch();
update(1);

incrementAndGet():

long value = update(1); // make sure withReturnBody == true

[1] https://github.com/basho/riak-java-client 
[2]https://github.com/basho/riak-java-client/tree/develop/src/main/java/com/basho/riak/client/operations

-- 
Dave Rusek
Basho Technologies
@davidjrusek

On January 24, 2014 at 8:41:07 AM, Guido Medina (guido.med...@temetra.com) 
wrote:

Hi,

Is there any small doc that could explain its usage a little bit:

From the Java perspective it would be nice if it point out its counter part 
methods with Atomic Integer like:
How to create it? Does incrementing a counter will just create it with zero as 
initial value and then increment it? What if you need to know its value and 
then increment it before it is created? (getAndIncrement)
get()
getAndIncrement()
incrementAndGet()
Regards,

Guido.
___  
riak-users mailing list  
riak-users@lists.basho.com  
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com  
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


Re: Riak Java client counter object

2014-01-28 Thread Dave Rusek
Guido,

There is no special way to list the values for all counters in a bucket. You 
will have to list the keys for the bucket (with a bucket type property 
‘datatype=counter’) then fetch the values for those keys (e.g. via 
multi-fetch). Depending on your use case and the number of counters, you may be 
able to create a map of counters (‘datatype=map’). This would be an easy way to 
fetch/update multiple counters in one operation.

-- 
Dave Rusek
Software Engineer
Basho Technologies
@davidjrusek

On January 28, 2014 at 4:29:28 AM, Guido Medina (guido.med...@temetra.com) 
wrote:

Hi,

Following up on this question, is there a way to list (not multi-fetch, just 
list) the existing counters in a bucket?

Regards,

Guido.

On 24/01/14 22:01, Dave Rusek wrote:
Guido,

I’m sorry, there are not currently any docs available. Rest assured they are a 
work in progress. In the meantime, please feel free to check-out the current 
pre-release [1]. The pre-release covers the low level API we have built on top 
of the PB interface. There is a start to a friendlier API in the develop branch 
of riak-java-client [2].

If you would like to get started with the low level API to begin getting a feel 
for Riak datatypes, I have included a few snippets that will hopefully help. 
The counters (and the data structures in general) are implemented as two 
separate operations: Fetch and Update. Updating a counter that does not exist 
will create it and initialize it to the given value. Fetching a counter that 
has not had a value stored will return an empty value.

While the low level API does not have convenience methods for getAndIncrement 
and the like, they can all be easily accomplished given fetch and update. It 
would clearly be easy for us to provide methods for these typical access 
patterns and in fact, it is something we are planning on doing.

RiakCluster cluster = …
BinaryValue bucket = …
BinaryValue key = …
BinaryValue type = ...

fetch():

DtFetchOperation get = 
new DtFetchOperation.Builder(bucket, key)
.withBucketType(type)
.build();

DtFetchOperation.Response response = cluster.execute(get).get();

long value;
CrdtElement element = response.getCrdtElement();
if (crdtElement.isCounter()) {
value = element.getCounter().getValue();
} else {
... 
}

update():

DtUpdateOperation update = 
new DtUpdateOperation.Builder(bucket, key)
.withBucketType(type)
.withReturnBody(true)
.withOp(new CounterOp(1)) // increment by 1
.build();

DtUpdateOperation.Response response = cluster.execute(update).get();

long value;
CrdtElement element = response.getCrdtElement();
if (crdtElement.isCounter()) {
value = element.getCounter().getValue();
} else {
... 
}

getAndIncrement();

long value = fetch();
update(1);

incrementAndGet():

long value = update(1); // make sure withReturnBody == true

[1] https://github.com/basho/riak-java-client 
[2]https://github.com/basho/riak-java-client/tree/develop/src/main/java/com/basho/riak/client/operations

-- 
Dave Rusek
Basho Technologies
@davidjrusek

On January 24, 2014 at 8:41:07 AM, Guido Medina (guido.med...@temetra.com) 
wrote:

Hi,

Is there any small doc that could explain its usage a little bit:

From the Java perspective it would be nice if it point out its counter part 
methods with Atomic Integer like:
How to create it? Does incrementing a counter will just create it with zero as 
initial value and then increment it? What if you need to know its value and 
then increment it before it is created? (getAndIncrement)
get()
getAndIncrement()
incrementAndGet()
Regards,

Guido.
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

___  
riak-users mailing list  
riak-users@lists.basho.com  
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com  
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


Re: pagination over 2i indexes in java

2014-02-11 Thread Dave Rusek
Joe,

I added an integration test to the 1.4.x-develop and the 1.4.4 branch of the 
client and tried them against the latest 1.4 branch of Riak but was not able to 
reproduce your issue.

https://github.com/basho/riak-java-client/tree/1.4.x-develop

-- 
Dave Rusek
Software Engineer
Basho Technologies
@davidjrusek

On February 11, 2014 at 5:21:11 PM, Brian Roach (ro...@basho.com) wrote:

-- Forwarded message --  
From: joe dude   
Date: Tue, Feb 11, 2014 at 2:15 PM  
Subject: Re: pagination over 2i indexes in java  
To: Brian Roach   
Cc: "riak-users@lists.basho.com"   


I'm using 1.4.4, and creating a PBClusterClient.  

Thanks.  


On Tuesday, February 11, 2014 11:03 AM, Brian Roach  wrote:  
Hi Joe -  

What version of the Riak Java client are you using, and which protocol  
(PB or HTTP)?  

Will take a look at it.  

Thanks!  
- Roach  

On Tue, Feb 11, 2014 at 11:50 AM, joe dude  wrote:  
> Hi, trying to figure out how to use the java client to do 2i index queries  
> with pagination.  
>  
> I can issue the query with max_results and get back exactly the number that  
> i asked for, but the continuation value in the returned StreamingOperation  
> object is null.  
>  
> In contrast, i get pagination to work just fine using the examples from:  
> http://docs.basho.com/riak/latest/dev/using/2i/  
>  
> I'm using:  
>  
> public StreamingOperation fetchIndex(IndexSpec indexSpec)  
> throws IOException  
>  
>  
> It's as if i'm missing something when building IndexSpec, but not sure what.  
>  
> Thx.  
>  
>  
> ___  
> riak-users mailing list  
> riak-users@lists.basho.com  
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com  
>  
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


Re: pagination over 2i indexes in java

2014-02-11 Thread Dave Rusek
Joe,

Sorry, I wanted to get that email out before I stepped out. The specific test I 
added is here:

https://github.com/basho/riak-java-client/blob/1.4.x-develop/src/test/java/com/basho/riak/client/itest/ITestBucket.java#L280

Does this represent your use case? If not, do you happen to have a failing test 
I could take a look at? 

Thanks!

-- 
Dave Rusek
Software Engineer
Basho Technologies
@davidjrusek

On February 11, 2014 at 5:33:57 PM, Dave Rusek (dru...@basho.com) wrote:

Joe,

I added an integration test to the 1.4.x-develop and the 1.4.4 branch of the 
client and tried them against the latest 1.4 branch of Riak but was not able to 
reproduce your issue.

https://github.com/basho/riak-java-client/tree/1.4.x-develop

-- 
Dave Rusek
Software Engineer
Basho Technologies
@davidjrusek

On February 11, 2014 at 5:21:11 PM, Brian Roach (ro...@basho.com) wrote:

-- Forwarded message --
From: joe dude 
Date: Tue, Feb 11, 2014 at 2:15 PM
Subject: Re: pagination over 2i indexes in java
To: Brian Roach 
Cc: "riak-users@lists.basho.com" 


I'm using 1.4.4, and creating a PBClusterClient.

Thanks.


On Tuesday, February 11, 2014 11:03 AM, Brian Roach  wrote:
Hi Joe -

What version of the Riak Java client are you using, and which protocol
(PB or HTTP)?

Will take a look at it.

Thanks!
- Roach

On Tue, Feb 11, 2014 at 11:50 AM, joe dude  wrote:
> Hi, trying to figure out how to use the java client to do 2i index queries
> with pagination.
>
> I can issue the query with max_results and get back exactly the number that
> i asked for, but the continuation value in the returned StreamingOperation
> object is null.
>
> In contrast, i get pagination to work just fine using the examples from:
> http://docs.basho.com/riak/latest/dev/using/2i/
>
> I'm using:
>
> public StreamingOperation fetchIndex(IndexSpec indexSpec)
> throws IOException
>
>
> It's as if i'm missing something when building IndexSpec, but not sure what.
>
> Thx.
>
>
> ___
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
___
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com