Open RockScience opened 11 years ago
I suspect line 64 of RMongo / src / r-mongo-scala / src / main / scala / rmongo / RMongo.scala is not parsing correctly arrays of documents:
64: JSON.parse(query).asInstanceOf[DBObject]
To make this fix, i think you'll need to make another function named dbInsertDocuments and typecast to a List[DBObject] instead of DBObject on L64 as you mentioned.
Additionally, it helps to add a unit test to verify the fix. To compile and run the tests, just run:
mvn compile
and mvn test
You'll need Maven 3/Java 7+ installed.
On Mon, Oct 28, 2013 at 12:22 AM, RockScience notifications@github.comwrote:
I suspect line 64 of RMongo / src / r-mongo-scala / src / main / scala / rmongo / RMongo.scala is not parsing correctly arrays of documents:
64: JSON.parse(query).asInstanceOf[DBObject]
— Reply to this email directly or view it on GitHubhttps://github.com/tc/RMongo/issues/22#issuecomment-27193043 .
Tommy Chheng
Any progress on this? Being able to send arrays of documents without a loop is a native feature of mongodb API which is very important for a scripting language like R.
Hi, if you submit a pull request with the suggested changes above, i'll be more than happy to review and merge.
Is dbInsertDocument a simple wrapper of db.collection.insert() ?
According to http://docs.mongodb.org/manual/reference/method/db.collection.insert/#db.collection.insert it should support batch sending from an array of document:
[document1, document2, ..., documentN]
This is important because R is not a compiled language and doesn't deal well with loops. Hence not being able to send a batch of documents will create unnecessary delays.
See also StackOverflow question: http://stackoverflow.com/questions/19564321/how-to-send-multiple-documents-using-rmongo