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
Some context moved from the original PR regarding the match statement to parse TableProperties:
I think you're correct and the rust compiler doesn't (at least in 1.73 stable) implement anything fancy here - according to quick chatGPT inquiry
after doing the simple thing, we could optimize by:
leverage custom Deserialize from serde for constant-time lookup (/linear-time loop).
pros: well-known efficient solution, elegant annotations on the struct for e.g. renaming the field for deserialization
cons: Extra overhead from serde considering we have such a constrained case of only ever deserializing from a HashMap<String, String>, code complexity of custom Deserialize
leverage HashMap-based lookup instead of the match for constant-time. could even use a crate like phf to get compile-time generation of perfect hash functions for string matching.
## What changes are proposed in this pull request?
New `TableProperties` struct parses the `Metadata` action's
`configuration` into a strongly-typed configuration struct. Instead of
previously manually querying specific keys (e.g. checking ColumnMapping
key) we can leverage the configuration to appropriately handle DVs,
column mapping, etc. in a structured manner.
Pragmatically, the changes are:
1. New `TableProperties` struct along with new
`Snapshot::get_table_properties()` API
a. Note that every field is optional and additionally there is an
`unknown_properties` field which includes a hashmap of all fields that
did not parse to a known table property.
2. `table_properties` module including deserialization submodule to
implement functions to deserialize the fields of `TableProperties`
### Future work
- optimize/test/improve interval parsing:
#507
- introduce a facility to query protocol + table properties to unify
checks on e.g. column mapping mode/dv enablement/etc.
#508
- docs #519
- #535
## This PR affects the following public APIs
- New `TableProperties` and `Snapshot::get_table_properties` API
## How was this change tested?
new ut
Credit: @roeap for the original PR which this is based on #222
Some context moved from the original PR regarding the
match
statement to parseTableProperties
:I think you're correct and the rust compiler doesn't (at least in 1.73 stable) implement anything fancy here - according to quick chatGPT inquiry
after doing the simple thing, we could optimize by:
Deserialize
fromserde
for constant-time lookup (/linear-time loop).serde
considering we have such a constrained case of only ever deserializing from aHashMap<String, String>
, code complexity of customDeserialize
HashMap
-based lookup instead of thematch
for constant-time. could even use a crate likephf
to get compile-time generation of perfect hash functions for string matching.ref: #453 (comment)
The text was updated successfully, but these errors were encountered: