Uh oh!
There was an error while loading. Please reload this page.
Reducing limit over the life of a datastore query iterator. - #1787
Conversation
dhermes
commented
May 11, 2016
Sorry for the delay @pcostell! |
| break | ||
| if self._limit is not None: | ||
| self._limit -= len(self._page) | ||
| self.next_page() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
commented
May 12, 2016
@pcostell PTAL, I also added logic for the |
| if self._limit is not None: | ||
| self._limit -= num_results | ||
| if self._offset is not None: | ||
| self._offset += num_results |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
commented
May 13, 2016
@pcostell You just mentioned that offset shouldn't be used to continue a query. You mean offset on it's own? Like without the end cursor? |
| if self._offset is not None: | ||
| # NOTE: The offset goes down relative to the location | ||
| # because we are updating the cursor each time. | ||
| self._offset -= num_results |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pcostell
commented
May 13, 2016
Sorry: When a query is continued, it may contain an offset. But like the limit the offset should always be decreasing. What I really mean: Always use a cursor to step to the next batch of a query, never an offset. Sometimes you need to go through batches of offset, in which you'll issue multiple queries with decreasing offsets. This is ok. |
dhermes
commented
May 17, 2016
@pcostell PTAL. |
| @@ -382,7 +381,7 @@ class Iterator(object): | |||
| _query_pb2.QueryResultBatch.MORE_RESULTS_AFTER_LIMIT, | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
commented
May 17, 2016
| self.assertTrue(iterator._query is query) | ||
| self.assertEqual(iterator._limit, None) | ||
| self.assertEqual(iterator._offset, 0) | ||
| self.assertEqual(iterator._offset, None) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tseaver
commented
May 17, 2016
Tests for |
dhermes
commented
May 17, 2016
@tseaver Good call. Check out the latest commit. |
tseaver
commented
May 17, 2016
LGTM |
In the process, also keeping tracking of the number of skipped results (so that we can update the offset). Fixesgoogleapis#1763.
dhermes
commented
May 17, 2016
Squashed commits. Will merge once Travis passes. |
Fixes#1763.
/cc @pcostell