-
Notifications
You must be signed in to change notification settings - Fork 25
Speedup/refactor proposal for rforcecom.query #22
Comments
Another advantage of the above is that I think it will work with arbitrarily deep nested queries (e.g. |
@ax42 I wrote a separate function just for parsing query response XML that can handle nested parent-child relationships and follows an algorithm similar to your suggested pseudocode. You can find that function on a branch in my forked repository: https://github.com/ReportMort/RForcecom/blob/query-refactor/R/rforcecom.utils.R You can download and test this improved version of
This function will obey your global setting for stringsAsFactors = F, so that addresses Issue #21 and it also handles the nested relationships described in Issue #15. The one thing is that it no longer uses One last thing I didn't test for an improvement in speed, but I think the lower bound on performance is always going to be how fast you can parse the XML, which is tough to get going quickly when it's millions of characters long. That said, I'm not sure how much we can optimize at the moment, but would love your input. |
Thanks -- I'll try and poke around with it on Sunday. Splitting things into pieces makes it easier to measure, and then if necessary, refactor them one-by-one. |
FWIW, I'll be using line profiling as detailed here: http://adv-r.had.co.nz/Profiling.html One of the quotes from that page is "unlist(x, use.names = FALSE) is much faster than unlist(x)" so there may already be a quick win there. |
First report back:
I'm passing the result of |
Thanks for checking. I just committed a new version of Seemingly Working Queries:
|
I have an idea on how to improve up rforcecom.query, but I'm struggling with the mechanics of the XML, so if someone can point me in the right direction (@reportmort?) that would be helpful.
I think the function should run as follows:
//records
(into a list?)//done
entry, if it's false//records
into the list(?) aboveParentName.ChildName
(so theName
child in theOpportunity
record becomeOpportunity.Name
I think this will be faster / cleaner than the existing code (which builds an empty data.frame and then populates cell-by-cell) as it can also use locators which are hopefully quite optimised.
So far, I've got:
..but as I said, I'm really struggling with getting the XML stripped apart.
The text was updated successfully, but these errors were encountered: