-
Notifications
You must be signed in to change notification settings - Fork 37
Iterable interface for IOperation #252
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Signed-off-by: Levko Kravets <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
==========================================
+ Coverage 92.91% 93.06% +0.14%
==========================================
Files 64 65 +1
Lines 1553 1586 +33
Branches 275 280 +5
==========================================
+ Hits 1443 1476 +33
Misses 46 46
Partials 64 64 ☔ View full report in Codecov by Sentry. |
benc-db
approved these changes
May 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an iterable interface for IOperation. Iterators provide a convenient way to process results using
for await .. of
loop.Two new methods are offered:
IOperation.iterateChunks()
- allows to process results like the one would previously do usinghasMoreRows
+fetchChunk
in a loop;IOperation.iterateRows()
- allows to iterate over individual rows.Both methods take the same options as
IOperation.fetchChunk
. In addition, settingautoClose: true
will close the operation when iterator is finished. By default this option isfalse
(do not close operation after iterating).Due to its nature,
IOperation
can only supply chunks of records. It means thatiterateChunks
is somewhat more efficient thaniterateRows
, because the latter internally also takes chunks and uses nested loop to walk over the rows. But iterating over rows seems to be quite a common use case for the library, thereforeiterateRows
was also added for convenience.Important. Since query results can be only retrieved sequentialy from beginning to the end, attempt to use multiple iterators on the same operation may result in unpredictable behavior. Stick with a straightforward use case, when a single
for await .. of
loop is used to walk through all results from beginning to end. It is allowed to use abreak
statement within the loop, but after that don't attempt to use iterators for that operation again.