3 ms·
Thanks for the detailed feedback, I appreciate it! I plan on writing more about all the topics you mentioned, and add docs for writing adapters and queries. I
by obi1kenobi 4y ago
Thanks for the detailed feedback, I appreciate it!
I plan on writing more about all the topics you mentioned, and add docs for writing adapters and queries. I was planning on doing a "Show HN" when more of that was in place, but I'm not the OP here -- someone else submitted it :) Obviously all of the below needs to be more discoverable, and is something I'll work on!
Here are the slides from my talk from the HYTRADBOI conference last year, containing some more real-world query use cases: https://docs.google.com/presentation/d/1foUdlEDOQ1WcTadhAxsATJ0yDbZwtr40JclJFArUVeY/edit?usp=sharing https://docs.google.com/presentation/d/1foUdlEDOQ1WcTadhAxsA...
This is the current stable adapter API: it's a trait that adapters need to implement https://docs.rs/trustfall_core/latest/trustfall_core/interpreter/basic_adapter/trait.BasicAdapter.html https://docs.rs/trustfall_core/latest/trustfall_core/interpr...
It's also available in the Python bindings: https://github.com/obi1kenobi/trustfall/blob/pytrustfall-v0.1.6/pytrustfall/trustfall/adapter.py#L22 https://github.com/obi1kenobi/trustfall/blob/pytrustfall-v0....
Tl;Dr of the optimizations API is that every call into the adapter gets a reference to a `QueryInfo` struct. It's totally safe to ignore if the adapter isn't interested in optimizing, and otherwise allows the adapter to ask questions like "from this location in the query, will future operations include traversing edge X and then filtering on property Y?" If so, it's possible to use the API to resolve the expected values for that Y property and use them to speed up the lookup, as in the case with the hashtables in cargo-semver-checks.
The optimizations API is still pretty raw and I didn't want to dig into it too much in that post (which is mostly about cargo-semver-checks' architecture, not just Trustfall internals) in case it changed dramatically. If you really want to see the current state of the API, here's a link to the draft PR: https://github.com/obi1kenobi/trustfall/pull/131/files#diff-7d824232cb78ba5b9057259aedd7a0bec18d6eeb9c558e7f471fb808c1c7453dR21-R107 https://github.com/obi1kenobi/trustfall/pull/131/files#diff-...
- ToJans 4y agoA small suggestion for your docs: instead of using foo and bar, you might be better off using well known examples, like cart and items, or projects and tasks. This usually helps to understand the context. One might even add a schema of the explainer context in the documentation somewhere.
- obi1kenobi 4y agoGood call, thank you! I'll almost certainly do something along those lines.