iroha
iroha copied to clipboard
feat(queries): Report amount of remaining items in query
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
ExactSizeIteratorimplementation 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
ExactSizeIteratoronQueryIteratorpretty naturally.
Checklist
- [x] I've read
CONTRIBUTING.md. - [x] I've written an integration test for the code changes.
- [ ] All review comments have been resolved.
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?
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