hyperledger-archives / fabric

THIS IS A READ-ONLY historic repository. Current development is at https://gerrit.hyperledger.org/r/#/admin/projects/fabric . pull requests not accepted
https://gerrit.hyperledger.org/
Apache License 2.0
1.17k stars 1.01k forks source link

Partial Keys accepted by GetRows are *subsequences* of the key and not subsets #2319

Open iiiLiQuiDiii opened 8 years ago

iiiLiQuiDiii commented 8 years ago

Description

If we have a table with the following columns "A", "B", "C", "D" where the key is ACD, then the only valid partial keys are "A" , "AC" and "ACD". These are sequences and must always start from A (CA is invalid ), also there cannot be holes ( "AD" is invalid ).

Is there a way to have partial keys as proper subsets instead of sequences? If not, are there plans for implementing it?

Describe How to Reproduce

deploy github.com/hyperledger/fabric/bddtests/chaincode/go/table

{"Function":"insertRowTableTwo", "Args": ["1", "2", "3", "4" ]}'

{"Function": "getRowsTableTwo", "Args":["1"] }' returns a result {"Function": "getRowsTableTwo", "Args":["3"] }' returns null {"Function": "getRowsTableTwo", "Args":["4"] }' returns null

"Function": "getRowsTableTwo", "Args":["1","3"] } returns a result "Function": "getRowsTableTwo", "Args":["3","1"] } returns null "Function": "getRowsTableTwo", "Args":["3","4"] } returns null "Function": "getRowsTableTwo", "Args":["1","4"] } returns null

"Function": "getRowsTableTwo", "Args":["1","3","4"] } returns a result

iiiLiQuiDiii commented 8 years ago

A quick solution to obtaining tuples with the partial key "CD" is to iterate over all the possible instances of A. Let's say A can be one of {1, 5, 6} , we can query for "1-C-D" , "5-C-D". "6-C-D" and merge the results. If ||A|| is big it may be necessary to rearrange the table key.