iroha icon indicating copy to clipboard operation
iroha copied to clipboard

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

Open DCNick3 opened this issue 1 year ago • 2 comments

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

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

DCNick3 avatar Aug 28 '24 07:08 DCNick3

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?

Erigara avatar Aug 29 '24 06:08 Erigara

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

DCNick3 avatar Aug 29 '24 06:08 DCNick3