Use a more ergonomic representation for StructuredMap keywords #239

Open
opened 2020-08-06 16:57:11 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:57:11 +00:00 (Migrated from github.com)

StructuredMap maps from keywords to various Binding instances (which can also be StructuredMaps).

Those keywords can come from the database, or they can be aliases provided by the user inside a query string.

For efficiency, the keys to the map are actually ValueRc<Keyword>, where all maps generated during a run share keys. That means lookup into the map requires creating an Arc!

More ergonomic ways to do this must exist.

We could have the keys to the map be references, or indices, or be in some way comparable to strings. Doing so would probably need some help from Rental.

We could push refcounting down into Keyword — after all, that's now just a more sophisticated box around a string.

We could explicitly intern keywords into some kind of enclosing result set 'context'. Doing so would impose a burden on the eventual consumer of results — it would no longer be meaningful to grab a map out of a result and pass it around without the context — but perhaps we could invert the relationship and have the dictionary itself be refcounted inside StructuredMap!

Lots of options, and a little thought needed.

`StructuredMap` maps from keywords to various `Binding` instances (which can also be `StructuredMap`s). Those keywords can come from the database, or they can be aliases provided by the user inside a query string. For efficiency, the keys to the map are actually `ValueRc<Keyword>`, where all maps generated during a run share keys. That means lookup into the map requires creating an `Arc`! More ergonomic ways to do this must exist. We could have the keys to the map be references, or indices, or be in some way comparable to strings. Doing so would probably need some help from [Rental](https://users.rust-lang.org/t/rental-0-5-released/17247). We could push refcounting down into `Keyword` — after all, that's now just a more sophisticated box around a string. We could explicitly intern keywords into some kind of enclosing result set 'context'. Doing so would impose a burden on the eventual consumer of results — it would no longer be meaningful to grab a map out of a result and pass it around without the context — but perhaps we could invert the relationship and have the dictionary itself be refcounted inside `StructuredMap`! Lots of options, and a little thought needed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#239
No description provided.