Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to parse R like queries to javascript Couch Views #3

Closed
sckott opened this issue Jun 20, 2013 · 22 comments
Closed

Add ability to parse R like queries to javascript Couch Views #3

sckott opened this issue Jun 20, 2013 · 22 comments

Comments

@sckott
Copy link
Contributor

sckott commented Jun 20, 2013

Important for R users that don't know javascript, which is likely many

@wactbprot
Copy link

Maybe Duncan has a starting point:

https://github.com/omegahat/RJavaScript

@sckott
Copy link
Contributor Author

sckott commented Jun 20, 2013

Ah, thanks very much!

@sckott sckott modified the milestone: v0.2 Nov 13, 2014
@andrewcstewart
Copy link

Hey @sckott , would this be the same thing as writing a CouchDB query server in R (similar to the python server) ?

@sckott
Copy link
Contributor Author

sckott commented Jan 15, 2015

@andrewcstewart not familiar with the couch query server? link?

@sckott
Copy link
Contributor Author

sckott commented Jan 15, 2015

@andrewcstewart
Copy link

http://docs.couchdb.org/en/latest/query-server/protocol.html

CouchDB's Views can be written in any language that a query server has been implemented for. For example you can write your view functions in python using http://couchdb-python.googlecode.com/svn/trunk/couchdb/view.py

I've started working out how to write a query server in R. Not sure if that's within the scope of what you're trying to do with this issue item, but might be of interest?

@sckott
Copy link
Contributor Author

sckott commented Jan 16, 2015

Possibly. What is the use case for query server in R?

@andrewcstewart
Copy link

The general use case would be for anyone who wants to write their View functions in R instead of javascript/erland/python, etc.  

A more specific example:  I and my team do data analysis in R and are starting to use CouchDB as a database for our data and results.  Not everyone in our team is bilingual in R and javascript, so I’ve been investigating whether we could write our view functions in R instead.

I have the meat of the query server written (I/O, function handler, and implementations of the add_fun and map_doc functions).  I just need to write a couple more function handlers and work out some kinks with how Couch runs an R script.


Sent from Mailbox

On Fri, Jan 16, 2015 at 10:50 AM, Scott Chamberlain
notifications@github.com wrote:

Possibly. What is the use case for query server in R?

Reply to this email directly or view it on GitHub:
#3 (comment)

@sckott
Copy link
Contributor Author

sckott commented Jan 16, 2015

@andrewcstewart That sounds great. That is the goal of this issue to figure out how to let users write views in R instead of javascript, so this is perfect.

Would you be interested in contributing code to this pkg? You'd definitely be an author

@andrewcstewart
Copy link

Absolutely.  We’ve been actively using your library to talk to couch from R, so it’s a perfect fit for this.  The only question I would have is how a standalone Rscript is handled with the R package format.  Installing the Rscript would take place on CouchDB’s side of things by adding the path to the script to Couch’s config file.  That can actually be done through REST call I believe, so perhaps it could be done directly from the R package?

library(sofa)
sofa.install_server(“http://127.0.0.1:5984”,user,pass)

etc..


Sent from Mailbox

On Fri, Jan 16, 2015 at 3:10 PM, Scott Chamberlain
notifications@github.com wrote:

@andrewcstewart That sounds great. That is the goal of this issue to figure out how to let users write views in R instead of javascript, so this is perfect.

Would you be interested in contributing code to this pkg? You'd definitely be an author

Reply to this email directly or view it on GitHub:
#3 (comment)

@sckott
Copy link
Contributor Author

sckott commented Jan 17, 2015

Hmmm, I think that would work fine. Just pass a file path to a function that get ingested by Couch.

@andrewcstewart
Copy link

Great. I can do a pull request as this gets closer to being functional. My only question would be where to place the Rscript file. Any suggestion?

@sckott
Copy link
Contributor Author

sckott commented Jan 19, 2015

Is the script something that changes/needs use input based before using, or is it not meant to be edited? If the latter, it can be stored in the package itself. If former, we could store a template maybe, then user has to edit it, then pass that in. Sorry if I'm not making sense, trying to make sense of how this is used

@andrewcstewart
Copy link

The script is a static I/O pass-through.  It listens for JSON from couchdb and return JSON back to it.   It’s basically just an R implementation of the following python script: http://couchdb-python.googlecode.com/svn/trunk/couchdb/view.py


Sent from Mailbox

On Mon, Jan 19, 2015 at 12:04 PM, Scott Chamberlain
notifications@github.com wrote:

Is the script something that changes/needs use input based before using, or is it not meant to be edited? If the latter, it can be stored in the package itself. If former, we could store a template maybe, then user has to edit it, then pass that in. Sorry if I'm not making sense, trying to make sense of how this is used

Reply to this email directly or view it on GitHub:
#3 (comment)

@sckott
Copy link
Contributor Author

sckott commented Jan 19, 2015

Okay, when you send PR, put the file in inst/extdata/ https://github.com/sckott/sofa/tree/master/inst/extdata I'm not sure that's the final place it should be, but once it's in the pkg, we can play around with the best spot for it.

@andrewcstewart
Copy link

hey @sckott I'm adding the script to my fork now. Do you have any preference for what to name the function that loads the R script into CouchDB?

@andrewcstewart
Copy link

More on that note:
It looks like the API call to couch's config would be something like

curl -X PUT http://[localhost]/_config/query_servers/R "/sofa/inst/extdata/view.R"

The drawback here though is that I think this will only work on the same host as CouchDB. (http://stackoverflow.com/questions/15456989/setting-up-a-python-viewserver-for-couchdb)

@sckott
Copy link
Contributor Author

sckott commented Jan 26, 2015

@andrewcstewart no, no preference on the fxn name.

Hmm, is that a huge problem if it only work son the same host as couch?

@andrewcstewart
Copy link

I’ve got to imagine that there’s some way to do it, even if it involves something like uploading the script to CouchDB as an attachment and referencing the destination path in the config.

On the other hand, since the CouchDB host will need to be running R anyway in order to use a query server written in R, maybe it’s not that unreasonable of a requirement to have the sofa package installed on the CouchDB host?


Sent from Mailbox

On Mon, Jan 26, 2015 at 10:02 AM, Scott Chamberlain
notifications@github.com wrote:

@andrewcstewart no, no preference on the fxn name.

Hmm, is that a huge problem if it only work son the same host as couch?

Reply to this email directly or view it on GitHub:
#3 (comment)

@sckott
Copy link
Contributor Author

sckott commented Jan 26, 2015

Sounds good

@andrewcstewart
Copy link

Just to update:

So I've got the basics down for this, though I need to still add the exception handling and the reduce function handlers. It should work in theory, though it's not passing my tests yet. I need to troubleshoot it a bit, but I can pull request prematurely if you're interested in seeing how it works so far.

@sckott sckott modified the milestones: v0.2, v0.3 May 6, 2016
@sckott
Copy link
Contributor Author

sckott commented Oct 20, 2017

@andrewcstewart don't know if you're still interested, sorry i missed this many years ago 😢

@sckott sckott removed this from the v0.3 milestone Oct 20, 2017
@sckott sckott closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants