-
Notifications
You must be signed in to change notification settings - Fork 0
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
Upgrade to abstract-level interface #11
Comments
I want to change the API interface to:
So that way And a way to create deeply nested levels more easily: Level/subleveldown#112 |
We should remove any usage and management of sublevels. Unless the sublevels themselves are just DB objects. But mostly it should be possible to just directly use the The APIs between // root iterator at dataDb
DB.iterator(options);
// same
DB.iterator(options, []);
// down level 1
DB.iterator(options, ['level1']);
DB.iterator(options, ['level1', 'level2]);
DBTransaction.iterator(options, ['level1', 'level2']);
DB.count();
DB.count(['level1', 'level2']);
DBTransaction.count();
DBTransaction.count(['level1']);
DB.clear();
DB.clear(['level1']);
DBTransaction.clear(['level1']); // this should be a transactional clear, to do this, we must iterator and then do `db.del`
DB.get('key');
DB.get(['level1', 'key']);
// these are not allowed, or they are equivalent to asking for undefined
DB.get([]);
DB.get();
DB.put('key', 'value');
DB.put(['level1', 'key'], 'value');
DB.del('key');
DB.del(['level1', 'key']);
DBTransaction.del('key');
DBTransaction.del(['level1', 'key']); |
We will need to test and benchmark sublevel creation multiple times to see how fast we can do this though, because somethings like iterator and count will require creating those sublevels. |
Some benchmarking results show that naively creating sublevels in order to support the key paths API or the domain APIs is quite slow:
Therefore it appears that if we want to have an efficient implementation, instead of just creating intermediate sublevel objects, we instead should be doing key path/prefix concatenation. Now this is what we do when we use For
Our in our case: subleveldown(dbLevel, `foo${utils.prefix}bar`)
// or
subleveldown(dbLevel, ['foo', 'bar']) |
I suggest that we remove subleveldown entirely, and just allow key paths for both iterators and get, put, del and clear... etc. Most custom operations like I reckon it would be something like this: iterator({
// gt means greater than this key
// since !A!B! would be the domain path, any key added would always be 1 character more
gt: '!A!B!',
// this would have to be the very next byte number above A!B, but that which doesn't produce an extra character, we could create a buffer and just increment by 1 the last byte
// if `!` is the separator which is 0x21, then plus 1 would be `"` which is 0x22
lt: '!A!B"'
}) Then we probably solve a number of problems. |
This script proves we can just use
I just realised that The |
With this prototype, I might just go ahead with getting rid of subleveldown entirely, and then that would make this 3.0.0 as the APIs are again different. Then that would affect PK quite significantly. |
Even without using subleveldown, the DB can still use |
I missed one thing, sublevels are actually indexed like this:
So between sublevels we have |
Due to #12, the 3.0.0 DB has been released and the interface shouldn't change all that much even with upgrade to abstract-level. |
#13 has enabled the ability to arbitrarily use level parts without worrying about reserved bytes. |
Specification
The abstract-level https://github.com/Level/abstract-level is a new foundation of LevelDB. Upgrading to this will help us resolve all other issues in DB.
bufferWrap
to supportArrayBuffer
,Uint8Array
andBuffer
#3 - abstract-level supports it directlyAbstractLevel
classic-level
(which is just leveldown atm) in NodeJS because NodeJS doesn't support indexed DB atm. But this should then basically makeDB
just an implementation of theabstract-level
interface.classic-level
that sets up root sublevels ofdata
,transactions
, andindex
and performs semi-transparent encryption & decryption (since it doesn't have a block level yet).iterator()
for read-committed level transactions, and true snapshots aren't really needed.index
root level#5 still cannot be solved until IDB becomes available, then we can use
browser-level
orlevel-js
and have the transparent encryption be done at the block level. Or done at the C++ level inside leveldb, or rocksdb.Wait until level has released version 8, although this can be started now, since we may not need to use the
level
package at all. The only dependencies ofjs-db
may beabstract-level
andclassic-level
.Additional context
Tasks
The text was updated successfully, but these errors were encountered: