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

feat(queries): Report amount of remaining items in query #5016

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

DCNick3
Copy link
Contributor

@DCNick3 DCNick3 commented Aug 28, 2024

Context

This PR allows the client to inspect the amount of items that is returned by the query without requesting all batches.

Closes #4984

Solution

  • I rely on ExactSizeIterator implementation applied to the pagination combinator. Filtering is not a problem, because we currently eagerly collect all items into a vector before returning anything.
  • To not introduce additional split between the type of result of initial and continuation queries, each iterable query response returns the remaining number of items in addition to the batch. This allows us to implement ExactSizeIterator on QueryIterator pretty naturally.

Checklist

  • I've read CONTRIBUTING.md.
  • I've written an integration test for the code changes.
  • All review comments have been resolved.

@github-actions github-actions bot added the api-changes Changes in the API for client libraries label Aug 28, 2024
@DCNick3 DCNick3 marked this pull request as draft August 28, 2024 08:04
@DCNick3 DCNick3 force-pushed the report-query-result-count branch 3 times, most recently from 76149b1 to 7a70461 Compare August 28, 2024 20:49
@DCNick3 DCNick3 self-assigned this Aug 29, 2024
@DCNick3 DCNick3 marked this pull request as ready for review August 29, 2024 05:53
@Erigara Erigara self-assigned this Aug 29, 2024
@Erigara
Copy link
Contributor

Erigara commented Aug 29, 2024

How this will work for SDKs?

To get total amount of items in the query they need to add number of remaining items (from the remaning field) + size of current batch?

@DCNick3
Copy link
Contributor Author

DCNick3 commented Aug 29, 2024

To get total amount of items in the query they need to add number of remaining items (from the remaning field) + size of current batch?

Yes, this is what rust SDK is also doing

Erigara
Erigara previously approved these changes Sep 3, 2024
mversic
mversic previously approved these changes Sep 4, 2024
core/src/query/cursor.rs Outdated Show resolved Hide resolved
@mversic mversic force-pushed the report-query-result-count branch from 7a70461 to e71b780 Compare September 4, 2024 03:33
…sedIterator::remaining` to hopefully be more clear

Signed-off-by: ⭐️NINIKA⭐️ <[email protected]>
@DCNick3 DCNick3 dismissed stale reviews from mversic and Erigara via 095f487 September 4, 2024 06:40
@mversic mversic merged commit 36bbf04 into hyperledger-iroha:main Sep 4, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] Provide a total amount of queryable items
3 participants