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

UniqueIndex range_de #500

Merged
merged 43 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2e04ac7
Impl `range_de` and `prefix_range_de` for indexes
uint Oct 20, 2021
ef55884
Test for UniqueIndex::range_de
uint Oct 20, 2021
fe57705
rename deserialize_unique_* fns for clarity
uint Oct 20, 2021
e4482ee
Fix UniqueIndex::range_de
uint Oct 20, 2021
c33c6a0
test IndexedMap range_de with composite keys
uint Oct 20, 2021
b6c0879
Add missing prefix_de / sub_prefix_de to UniqueIndex
maurolacy Oct 26, 2021
e959889
Fix UniqueIndex prefix + range deserialization test
maurolacy Oct 26, 2021
b5060f2
Add clarifying comment
maurolacy Oct 26, 2021
46f884c
Invert deserialize unique index fn args for consistency
maurolacy Oct 26, 2021
524864f
Add prefix_de / sub_prefix_de to MultiIndex
maurolacy Oct 26, 2021
53a6840
MultiIndex example with String primary key
maurolacy Oct 26, 2021
6da86e0
MultIndex example using String also for index key
maurolacy Oct 27, 2021
b369363
Fix: `MultiIndex` key deserializes to remaining key plus pk (`Map`-like)
maurolacy Oct 27, 2021
6bc3a13
Improve comment
maurolacy Oct 27, 2021
f98217a
Add entry about index key deserialization
maurolacy Nov 3, 2021
bc55252
Split indexes impl into different files
maurolacy Nov 3, 2021
759b493
Add iterator feature
maurolacy Nov 3, 2021
31d4826
Refactor indexes into its own module
maurolacy Nov 15, 2021
8ea1f22
Add sub_/prefix_de to SnapshotMap
maurolacy Nov 9, 2021
f9e4182
Adapt simple key tests to better show key deserialization
maurolacy Nov 9, 2021
3f0702f
Adapt composite key tests to better show key deserialization
maurolacy Nov 9, 2021
18ca487
Add prefix_de test
maurolacy Nov 9, 2021
eddddf0
Add missing keys_de shortcut
maurolacy Nov 9, 2021
1148c35
Add missing prefix_range_de to SnapshotMap
maurolacy Nov 9, 2021
3c2ce00
Add extra sub_prefix_de test
maurolacy Nov 19, 2021
4c8ca24
Add prefix_range_de test for completeness
maurolacy Nov 19, 2021
4db7407
Add sub_/prefix_de to SnapshotMap for completeness
maurolacy Nov 9, 2021
7f5b80f
Add sub_/prefix_de tests
maurolacy Nov 19, 2021
e5eafe6
Change test names for consistency
maurolacy Nov 19, 2021
f56f457
Change prefix_range_de tests to use string keys
maurolacy Nov 19, 2021
cae3ace
Remove unneeded clones
maurolacy Nov 19, 2021
c6d55d0
Add unique index key deserialization FIXMEs
maurolacy Nov 19, 2021
10ce6d6
Change unique index test names for consistency
maurolacy Nov 21, 2021
d4af909
Add range_/keys_de to IndexedSnapshotMap
maurolacy Nov 10, 2021
e070ab4
Add sub_/prefix_de to IndexedSnapshotMap for completeness
maurolacy Nov 10, 2021
535c8ff
Adapt tests to better work with deserializable values
maurolacy Nov 19, 2021
c16e798
Add range_de multi index tests
maurolacy Nov 19, 2021
30c6a50
Rename unique index range tests for consistency
maurolacy Nov 19, 2021
a2a9fd7
Add range_de unique index tests
maurolacy Nov 19, 2021
ba3099f
Add simple base sub_/prefix_/range_de tests for completeness
maurolacy Nov 21, 2021
61fb8e9
Merge branch 'main' into 461-uniqueindex-range_de
maurolacy Nov 24, 2021
49acea9
Extend Index keys deserialization docs
maurolacy Nov 24, 2021
b4203be
Clarify prefix_range/_de docs
maurolacy Nov 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/storage-plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,21 @@ Another example that is similar, but returning only the `token_id`s, using the `
.collect();
```
Now `pks` contains `token_id` values (as `Vec<u8>`s) for the given `owner`.

### Index keys deserialization

To deserialize keys of indexes (using the `*_de` functions), there are currently some requirements / limitations:

- For `UniqueIndex`: The primary key (`PK`) type needs to be specified, in order to deserialize the primary key to it.
This generic type comes with a default of `()`, which means that no deserialization / data will be provided
for the primary key. This is for backwards compatibility with the current `UniqueIndex` impl. It can also come handy
in cases you don't need the primary key, and are interested only in the deserialized value.

- For `MultiIndex`: The last element of the index tuple must be specified with the type you want it to be deserialized.
That is, the last tuple element serves as a marker for the deserialization type (in the same way `PK` does it in
`UniqueIndex`).

- There are currently some inconsistencies in the values that are returned for the different index keys. `MultiIndex`
returns a tuple with the remaining part of the index key along with the primary key, whereas `UniqueIndex` returns only
the primary key. This will be changed in the future (See https://github.com/CosmWasm/cw-plus/issues/532) for consistency
and compatibility with the base `Map` type behaviour.
Loading