-
Notifications
You must be signed in to change notification settings - Fork 139
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Document Views #1667
Comments
My first pass at how I think this can look for the first round: https://gist.github.com/rust-play/0cda7cc7eee6787ce9904742d154d89e |
Closed
github-merge-queue bot
pushed a commit
that referenced
this issue
Nov 7, 2023
## Description Implementation of #1667, extends #1701 With the following changes after discussions in Discord: * Remove the notion of views, instead embed the info in the query. If the high-level concept of views makes more sense for people from an API perspective, we can restore it in the client api. However under the hood the query details are different per view, this is why here I expose a single `Query` struct * Add a query builder with a typestate to only allow possible combinations * Add an index to the redb (fs) document store to make queries that are sorted by key, or that are filtered by key but not by author, efficient. This also is what allows to do queries for the "latest only" entry per key, without allocating the full result set. In the process I did a refactoring of the redb store to be safer to use. Especially, I moved the `ouroboros` self-referencing stuff into a `ranges` module, and encapsulated in an inner type to keep the self-referencing compilcations scoped. Also did something I had mind for a while: Add some type-safe abstractions around the range bounds constructions that are used when selecting on redb tables. All this turned out quite nice, IMO. Also contains the changes from #1772 : * Renames `get_one` to `get_exact` * Add flag to `get_exact` whether to include empty entries or not * Add `get_one` to `iroh::client::Doc` to get a single entry with the same query mechanisms as `get_many` Open questions and tasks: * Naming review of the query builder methods * Integration of the query parameters in the console ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [ ] Tests if relevant. --------- Co-authored-by: dignifiedquire <me@dignifiedquire.com>
Implemented and refined in #1766 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've had time to play with iroh a bunch now that prefix-based deletion is in, and I must say, it's been very fun learning how iroh works 馃槣. With that said, I think prefix deletion and author ID's as key prefixes are too much for a user to get their head around on first go. As a user when I hear "key value store", I expect all keys to be unique based solely on the key I provide.
We have some new UI that at least illustrates the problem:
In this example there are two
foo
keys in the same document, because they have different authors. What's more, because I am neither of these authors, I cannot edit these keys, which is super confusing. As someone who works at n0, I fully understand why I can't edit stuff in someone else's subspace, so I'm not advocating we change anything about the way iroh works, instead I want a new "views" feature that gives me a "merged" view of the document, which is a union of all known replica keys, using timestamps to break ties.Iroh is missing a true "shared" view of a document. I need this ASAP because it's too hard to introduce users to both the author-replica thing and the prefix thing at the same time. I think the right answer is to start with teaching prefix deletion, but have the default display be this merged view that will feel like a true key-value store. That shared view will naturally invite the "but wait, just anyone can edit the db!?" question, which will open us up to talk about how there are ways to change the view to match individual authors, or the full-blast "all" view.
Views
The term view here means "view" in the classical database sense:
We already have the concept of filters which perform largely the same function, but co-mingle querying with views:
iroh/iroh-sync/src/store.rs
Lines 141 to 155 in 8169053
I think the
All
andAuthor
are views, withKey
being an implicit query on theAll
view,AuthorAndPrefix
is an implict query on theAuthor
view.Merged View
A merged view takes the following steps:
key
fieldkey
field. last-writer wins for conflicts on the key field, lexographic sort ofauthor_id
wins in the event of equalkey
×tamp
fields.I'm sure the algorithm could be better. This is just how my dumb brain expresses "I want unique key fields, last-writer-wins, regardless of author"
Proposal:
filters
, split them intoqueries
andviews
all
(all keys from all authors),author
(only keys from one author), andmerged
(all keys in one space)--view
flagThe text was updated successfully, but these errors were encountered: