Atomic Counters from Spark

spark

#1

I am trying to increment my Couchbase counters from Spark code using scala. I am unable to find a way to do it. Have anyone tried it. Is there any sample code you can share to do this?


#2

As of couchbase spark connector 1.1, the counter is not exposed. However there is a way to grab the bucket from spark context and then perform teh counter operation.
Here is the code snippet:

val bucket = CouchbaseConnection().bucket(CouchbaseConfig(sc.getConf), "default") bucket.counter("<KEY>",1,1);

Thanks Michael Nitschinger for helping.


#3

Yes, that’s currently the best way. I’m looking on how to integrate it nicely into the API as well :slight_smile: