Skip to content
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

LITE-24467 Fix slicing for ResourceSet #46

Merged
1 commit merged into from
Jul 22, 2022

Conversation

bdjilka
Copy link
Contributor

@bdjilka bdjilka commented Jul 19, 2022

Now only for synchronous code. Async one will be later

@bdjilka bdjilka requested review from Sainomori, gab832 and a user July 19, 2022 14:40
@bdjilka bdjilka force-pushed the LITE-24467_fix_slicing_for_resourceset branch 2 times, most recently from e0c58d8 to a3a7c8a Compare July 21, 2022 10:40
raise
self._config['params']['offset'] += self._config['params']['limit']
items_to_fetch = self._rs._slice.stop - self._rs._content_range.last - 1
if items_to_fetch < self._config['params']['limit']:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably if items_to_fetch is 0 we can raise StopIteration instead of making the call or I'm wrong ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be, upper there is a condition self._rs._content_range.last >= self._rs._slice.stop - 1

@@ -124,6 +124,58 @@ async def _execute_request(self):
return results, content_range


class AbstractSliceIterator(AbstractBaseIterator):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this logic can be added to the AbstractIteration instead of having a new iterator class for slices, am I wrong ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractIteration caches results, tests showed, that it leads to different error. Moreover, AbstractIteration don't have def __iter__(self):

copy._slice = key
if copy._slice.stop - copy._slice.start < copy._limit:
copy._limit = copy._slice.stop - copy._slice.start
raise NotYetEvaluatedError()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit complicated for me to merge having fixed just sync client, can you do the same for async one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is in progress

@bdjilka bdjilka force-pushed the LITE-24467_fix_slicing_for_resourceset branch 3 times, most recently from 16b5859 to 7467c98 Compare July 22, 2022 10:10
@bdjilka bdjilka force-pushed the LITE-24467_fix_slicing_for_resourceset branch from 7467c98 to cd1bd48 Compare July 22, 2022 10:15
@bdjilka bdjilka requested a review from a user July 22, 2022 10:25
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's perfect, thank you @bdjilka 🥇

@ghost ghost merged commit 17f5074 into master Jul 22, 2022
@marcserrat marcserrat deleted the LITE-24467_fix_slicing_for_resourceset branch July 25, 2022 07:36
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant