Skip to content

Commit

Permalink
replace Metadata in query with Limit and Bookmark
Browse files Browse the repository at this point in the history
The range query receives metadata such as pagination limit.
The execute query at couchdb receives metadata such as the
pagination bookmark and pagination limit.
ValidateRangeMetadata() and ValidateQueryMetadata() validate
the received metadata.

However, the term metadata is confusing with the statemetadata
which stores the key-based endorsement. Hence, we replace
Metadata in range query API with limit and in the execute
query API with bookmark and limit. As we have removed the
metadata map, we also removed ValidateRangeMetadata()
and ValidateQueryMetadata() as they are not needed anymore.

Signed-off-by: senthil <cendhu@gmail.com>
  • Loading branch information
cendhu committed Apr 11, 2020
1 parent 217c3b0 commit 5ef925b
Show file tree
Hide file tree
Showing 24 changed files with 896 additions and 1,090 deletions.
11 changes: 7 additions & 4 deletions core/chaincode/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,9 @@ func (h *Handler) HandleGetStateByRange(msg *pb.ChaincodeMessage, txContext *Tra
startKey = metadata.Bookmark
}
}
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIteratorWithMetadata(namespaceID,
startKey, getStateByRange.EndKey, paginationInfo)
limit := paginationInfo["limit"].(int32)
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIteratorWithLimit(namespaceID,
startKey, getStateByRange.EndKey, limit)
} else {
rangeIter, err = txContext.TXSimulator.GetStateRangeScanIterator(namespaceID, getStateByRange.StartKey, getStateByRange.EndKey)
}
Expand Down Expand Up @@ -858,8 +859,10 @@ func (h *Handler) HandleGetQueryResult(msg *pb.ChaincodeMessage, txContext *Tran
return nil, err
}
isPaginated = true
executeIter, err = txContext.TXSimulator.ExecuteQueryWithMetadata(namespaceID,
getQueryResult.Query, paginationInfo)
bookmark := paginationInfo["bookmark"].(string)
limit := paginationInfo["limit"].(int32)
executeIter, err = txContext.TXSimulator.ExecuteQueryWithBookmarkAndLimit(namespaceID,
getQueryResult.Query, bookmark, limit)

} else {
executeIter, err = txContext.TXSimulator.ExecuteQuery(namespaceID, getQueryResult.Query)
Expand Down
174 changes: 88 additions & 86 deletions core/chaincode/mock/tx_simulator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 17 additions & 20 deletions core/committer/txvalidator/mocks/query_executor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ef925b

Please sign in to comment.