@zfedor to my knowledge there is no community contributed SDK for R and also no officially supported one.
But we do support a variety of others, maybe it is possible to call from R into one of the support languages? I know that there is some compatbility between R and C#/F#, so maybe you are able to hook it up with the .NET SDK?
Hi Servet,
Sure, actually it is pretty easy, just write up a Python module to communicate with Couchbase and then use the RPython R package to talk to your Python module.
Below is a pseudo-example for reading data from Couchbase. Writing would be about the same.
The R code: library(“rPython”) python.load(‘couchbase-R.py’, get.exception = TRUE)
key <- '10801’ python.assign(“key”, key) # set the key variable in Python to the key of the document I will want to get from Couchbase doc <- tryCatch({ python.exec(“doc=get_by_key(key)”) # call the Python function loading data out of Couchbase python.get(“doc”) # get the doc variable back from Python with the stringified JSON document }, warning = function(w) { # warning-handler-code }, error = function(e) { # error-handler-code doc <- NULL }, finally = { # cleanup-code }) doc
The Python module (sorry, indentations lost due to the forum editor not keeping them, so you will need to add those back to make it run): # couchbase from couchbase.bucket import Bucket from couchbase.exceptions import CouchbaseError
bucket = Bucket(‘couchbase://x.x.x.x/default’)
# get the content of a doc from couchbase by using the docid def get_by_key(key): try: doc = bucket.get(key)
except CoucbbaseError as e: print(“Couldn’t retrieve value for key”, e) # Rethrow the exception, making the application exit raise
do you have any plan to make R SDK or not?
as you know R is most powerful Statistic language and many of bigdata-users use language like R to make decision of big data.
@vhp1360 right now we don’t have plans for an R SDK but you can make use of Couchbase through the Spark Connector. We have first class spark integration and spark integrates well with R - is that a path you could pursue?