You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #163 (modifying same code logic, good to work on them one after another)
Currently in storage plus, indexes always return a byte key. One common pattern from SQL systems, to save access, is to only index a part of the data.
For example, if we wish to always know the first and last height of all open proposals as an O(1) query, we could create and index (status, height), and assuming #163, then prefix scan over Status::Open to find the first/last height. However, this requires maintaining an index for all the other statuses, we do not care about.
However, and index like INDEX height WHERE status = Status::Open (to borrow from SQL syntax) would only index currently open proposals and record their height, which is exactly what we need and no more.
Create two constructors
The first one new can work as is, and assume a complete index.
Add a second constructor that takes a partial indexing function.
Internally, you can either wrap the complete indexer as a partial indexer that always returns Some(x), or store the two as enum variants.
Update save and remove and test them
The text was updated successfully, but these errors were encountered:
Related to #163 (modifying same code logic, good to work on them one after another)
Currently in
storage plus
, indexes always return a byte key. One common pattern from SQL systems, to save access, is to only index a part of the data.For example, if we wish to always know the first and last height of all open proposals as an O(1) query, we could create and index (status, height), and assuming #163, then prefix scan over
Status::Open
to find the first/last height. However, this requires maintaining an index for all the other statuses, we do not care about.However, and index like
INDEX height WHERE status = Status::Open
(to borrow from SQL syntax) would only index currently open proposals and record their height, which is exactly what we need and no more.Design:
Indexing function is currently defined as:
index: fn(&T) -> Vec<u8>
(or with Support composite keys on secondary indexes (multi-index) #163index: fn(&T) -> K
)Define partial indexer as
index: fn(&T) -> Option<Vec<u8>>
(or with Support composite keys on secondary indexes (multi-index) #163index: fn(&T) -> Option<K>
)Create two constructors
The first one
new
can work as is, and assume a complete index.Add a second constructor that takes a partial indexing function.
Internally, you can either wrap the complete indexer as a partial indexer that always returns
Some(x)
, or store the two as enum variants.Update save and remove and test them
The text was updated successfully, but these errors were encountered: