-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Simplify run helpers? #43
Comments
Hey Oliver, To answer your question (from documentation) the differences are subtle but valuable differences. Each vary in strictness in what they can deserialize:
|
Ultimately, though, I like the way run helpers cover all response types without involving DLR. I was using the driver in my projects and I ran into situations where I wanted Imagine:
versus:
If you have better naming suggestions for the run helpers we could discuss those suggestions. |
Thanks Brian, I have read that documentation. I'm playing devil's advocate here. As the user of the library I don't quite see why there is a difference between
|
Hi @oliverjanik , No worries. 👍 Regarding 1We briefly had a technical discussion about this in the early days of the driver. I believe the discussion started here: #4 (comment) IIRC, So, Regarding 2
Regarding 3
Yes, I think so. In terms of aesthetics and style I think
You make a good point. I would agree that the protocol details have bled into run helpers (such as needing to know what your response type is: Thoughts? |
I'm running into a problem with Run helpers. I have a query like this:
Which returns Cursor, so I use RunCursor<>. Now when I modify the query like this:
It doesn't return cursor, it returns Atom. Which helper do I use to cover both cases? The orderby expression is appended on the fly. Edit: Should RunCursor support all response types including non streaming ones and just provide in memory shim for iteration? |
Hey @oliverjanik, depends on the response type. I'd need to see the protocol traces for each. There are two types of cursor responses: cursor Also, if you need any more help, I'm available on slack. http://slack.rethinkdb.com @bchavez |
One thing about run helpers that bothered me was the sort of ambiguous method overload
So, I've been thinking about renaming the 7.
The Go driver uses This will probably make it into 2.4 driver release with an |
Hi @bchavez This has bit me again. I have situation where a query gets built dynamically based on various parameters. This depending actual query that gets issued I can get one of 3 responses:
From my point of view I just need to return an array out of my API. Is there a single Run Helper method that covers the 3 scenarios? RunCursor does not handle SUCCESS_ATOM, RunResult<List> does not handle SUCCESS_PARTIAL. would it be possible for RunCursor to support SUCCESS_ATOM if the result is an array? |
Hi @oliverjanik, Pretty interesting problem and scenario. My initial thoughts are not to make contract changes to However, I think there is an escape hatch you can utilize. Specifically, the undocumented Basically, send your dynamic query down Normally, the Run Helpers, like RethinkDb.Driver/Source/RethinkDb.Driver/Net/Connection.cs Lines 327 to 344 in 0447498
RethinkDb.Driver/Source/RethinkDb.Driver/Net/Response.cs Lines 114 to 118 in 0447498
The A possible solution to your problem would probably involve having a run helper extension method that uses Let me know if you think this approach could help. Thanks, 🚶♂️ 🚶♀️ Missing Persons - Walking in L.A. |
Also, another approach could be to use some ReQL primitives that force the response object to always be |
My solution at the moment is to coerce everything to "array". I'm wondering if I lose out on benefits of actual cursors then. Or maybe it might strain the DB too much when requesting large dataset. I'm a simple man when I issue With RethinkDB it seems to decide on the fly what kind of response it gives. Makes things rather non-trivial when using the driver. I'm not sure how predictable the response type is, given same input. I'll look into the RunUnsafeAsync, that's my last resort. |
Thanks Oliver. I appreciate your perspective. Let me know if you get an implementation using Perhaps we can look at adding a new run helper like I've been planning to implement Goes without saying, much of what we do in programming has some kind of trade-off. Also, let's not forget the spirit of the run helpers is to avoid the performance hit from the DLR. Many of these helper methods are tools to help you get closer to the wire. As such, protocol details like this, unfortunately, bubble up through the API. |
I am voting for this feature/methods. It would simplify driver use cases for "end-programmer", because IEnumerable output is expected outcome from the "SELECT-like" queries. |
One one the first things that confused me was why are there so many Run* methods.
Let's see (excluding async versions):
object Run()
object Run<T>()
void RunNoReply()
Cursor<T> RunCursor<T>()
T RunAtom<T>()
T RunResult<T>()
Result RunResult()
Cursor<Change<T>> RunChanges<T>()
IEnumerable<GroupedResult<TKey, TItem>> RunGrouping<TKey, TItem>()
Why is (2) needed? If i give it a and it returns object it's not at useful as it could be. Here's suggestion:
object Run()
T Run<T>()
Cursor<T> RunCursor<T>()
If you need Result you'd just do
Run<Result>()
, if you need Atom you'd doRun<int>
.What do you think?
The text was updated successfully, but these errors were encountered: