-
-
Notifications
You must be signed in to change notification settings - Fork 34
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multilevel-down #64
Comments
@juliangruber N00b comment incoming. I'm not familiar with "how subleveldown fixes some issues". Anyone care to fill me in briefly or link to some issues involving this? |
to be honest, this seems sort of strange (subleveldown too) maybe this is a good idea... or maybe it is a good pattern. we are applying leveldown in quite a different way to what it was originally intended. It's not just a backend anymore... what is it? |
@dominictarr i agree with you that it might seem a bit change at first but i like the implement-as-leveldown pattern. some pros:
basically you just end up using leveldown as a "core leveldb" implementation instead of as a backend. @ralphtheninja in dat we've hit some weird edgecases with sublevels since they don't always behave exactly as levelups, fx dominictarr/level-sublevel#78 and https://github.com/rvagg/level-spaces/issues/3 which is why we started experimenting with implementing stuff as leveldowns (fx https://github.com/mafintosh/levelup-defaults and https://github.com/mafintosh/changesdown) |
This sounds really interesting. It feels like implementing a proper |
Yeah, it seems like leveldown is really the core primitive not the backend. I think the biggest question for me, is how does leveldown relate to encodings? because that is the part that really differs between multilevel and leveldown. Handling this would be the key thing to make level-sublevel be a leveldown... Basically, it sounds like we are talking about making leveldown composable. |
What do you mean by that's what differs between multilevel and leveldown? Leveldown expects strings or buffers, and multilevel can send strings and buffers |
Also, if multilevel were a leveldown, could we just reuse the sublevel logic without kind of hard coding it into multilevel? |
@jcrugzz there has also been talk of allowing leveldowns to handle encoding, so that when you have a leveldown that natively supports a highlevel encoding (i.e. typewise) you can do that. |
but this begs the question: what do we need levelup for? encoding and read streams? |
@dominictarr that's why i'm thinking we might end up having those features in two libs, like var db = encode(leveldown('./db'));
readStream(db).pipe(...) |
hm the only thing i'm not really sure about yet is whether monkeypatching leveldown is a good idea... |
@juliangruber Why do you need to monkeypatch leveldown? |
To add encodings to get and put I think |
couldn't the levelup just take care of that? |
@mafintosh i was thinking of whether we'd even need levelup, just leveldown with wrappers |
hmm interesting, |
@jcrugzz encoding doesn't always happen near the users. for example, in sublevel, each db adds a prefix (an array of strings) to the key, and then passes it to a core unit, which applies encodings and passes to leveldown. It helps a lot to not encode anything immediately, because then you still have access to it for pre/post hooks. I'm wondering, maybe we can have an abstract-leveldown-wrapper which takes a leveldown, returns a new leveldown, and provides pre and post methods which are called before a leveldown method is called, or after leveldown calls back. pre/post would allow you to change the argument, so you could apply an encoding, or transform the key... maybe pre/post could be async too? |
@dominictarr exactly what i was thinking! |
I had a plane ride today and took a stab at implementing multilevel as a leveldown (and using protobuf). The repo is mafintosh/multileveldown. The manifest stuff from multilevel is still missing since, at first iteration, it didn't seem to fit the leveldown pattern super well but everything else seems to work quite well and was pretty easy to implement. On the plus side encodings seems to work great since everything is just binary internally now. |
<3! I'm for keeping it separate until we discover in real world use cases which approach works better. My gut tells me though that it's gonna be multileveldown. I'm looking at that repo :) |
Similar to how subleveldown fixes some issues sublevel has (not judging whether it's better in total), let's discuss whether implementing multilevel as a backend would be more useful.
Some things to discuss:
What do you think?
From the top of my head: @dominictarr @hij1nx @ralphtheninja @substack @mafintosh @maxogden @feross @jcrugzz
The text was updated successfully, but these errors were encountered: