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

As a chaincode client, I would like to page through chaincode private data query results #4197

Open
denyeart opened this issue May 4, 2023 · 4 comments

Comments

@denyeart
Copy link
Contributor

denyeart commented May 4, 2023

Current Status

Public data queries can be paginated with bookmark and pagesize using these chaincode APIs:
GetStateByRangeWithPagination()
GetQueryResultWithPagination()
GetStateByPartialCompositeKeyWithPagination()

Similar chaincode APIs are not yet available for private data collections.

Expected

Chaincode client can pass pagesize and bookmark parameters to private data range, composite key, and rich query shim APIs in order to drive pagination.

Solution

Add corresponding chaincode APIs for private data.

Please let us know if you plan to work on this.

No.

@denyeart
Copy link
Contributor Author

denyeart commented May 4, 2023

See prior discussion and workaround in Jira at https://jira.hyperledger.org/browse/FAB-11732.

@bkiran6398
Copy link
Contributor

bkiran6398 commented Mar 29, 2024

See prior discussion and workaround in Jira at https://jira.hyperledger.org/browse/FAB-11732.

Hello @denyeart , given discussion reference is not accessible. Please provide the updated link if it is persistent somewhere else.

And I believe this comment on closed PR gives a glimpse of discussion.

@denyeart
Copy link
Contributor Author

denyeart commented Jun 5, 2024

from chanioxaris:

To implement this feature, changes are needed on two separate repositories:

Introduce a new API function on ChaincodeStubInterface interface, GetPrivateDataQueryResultWithPagination() that accepts a collection, query, pageSize and bookmark parameters.

Changes need to be applied on chaincode handler function HandleGetQueryResult() with a new case to  take into account if collection and metadata for pagination are set.

Also a new API function ExecuteQueryOnPrivateDataWithMetadata() is needed for QueryExecutor interface that accepts namespace, collection, query  and metadata parameters, that returns the already implemented ExecuteQueryWithMetadata() of state db interface

Finally a new API function ExecuteQueryOnPrivateDataWithMetadata() is needed for DB interface that accepts 

 

 I have already implemented a first version of this feature, although for v1.4 and needs to be ported to v2, that seems to working as expected after comparing the chaincode results with the CouchDB direct mango query results. If anyone is interested, can have a look at these changes at this specific commit [https://github.com/tradeline-tech/fabric/commit/67e4d5842bac3bd1951bd30ed74d16a123170250] of the forked fabric repo.

@denyeart
Copy link
Contributor Author

denyeart commented Jun 5, 2024

Workaround copied from Jira archive FAB-11732:

Workaround is to perform sorted queries.

  • For key range queries, pass the startKey of where you'd like to start or resume.
  • For JSON queries, utilize a sort and add a filter condition on the sorted field(s) of where you'd like to start or resume.
  • As you iterate through results in chaincode, it will retrieve from CouchDB in batches of 1000, as configured in core.yaml peer.ledger.state.couchDBConfig.internalQueryLimit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants