-
Notifications
You must be signed in to change notification settings - Fork 17
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
Comments
Maybe Duncan has a starting point: |
Ah, thanks very much! |
Hey @sckott , would this be the same thing as writing a CouchDB query server in R (similar to the python server) ? |
@andrewcstewart not familiar with the couch query server? link? |
@andrewcstewart views refers to these http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views |
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? |
Possibly. What is the use case for query server in R? |
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. — On Fri, Jan 16, 2015 at 10:50 AM, Scott Chamberlain
|
@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 |
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.. — On Fri, Jan 16, 2015 at 3:10 PM, Scott Chamberlain
|
Hmmm, I think that would work fine. Just pass a file path to a function that get ingested by Couch. |
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? |
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 |
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 — On Mon, Jan 19, 2015 at 12:04 PM, Scott Chamberlain
|
Okay, when you send PR, put the file in |
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? |
More on that note:
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) |
@andrewcstewart no, no preference on the fxn name. Hmm, is that a huge problem if it only work son the same host as couch? |
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? — On Mon, Jan 26, 2015 at 10:02 AM, Scott Chamberlain
|
Sounds good |
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. |
@andrewcstewart don't know if you're still interested, sorry i missed this many years ago 😢 |
Important for R users that don't know javascript, which is likely many
The text was updated successfully, but these errors were encountered: