-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Serialize compact range options #517
Conversation
db = testCommon.factory() | ||
db.open(t.end.bind(t)) | ||
make('test compactRange() frees disk space after key deletion', function (db, t, done) { | ||
db.batch().put(key1, val1).put(key2, val2).write(function (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Not sure what I prefer out of those options. I'm leaning towards 5. |
It's too bad that LevelDB doesn't support |
Option 5 also makes it easier to introduce promise support in the future, i.e. making the callback optional. To do that while also making compactRange(start, end, callback)
compactRange(start, callback)
compactRange(/* not-defined-signal */, end, callback)
compactRange(callback)
compactRange(start, end).then(..)
compactRange(start).then(..)
compactRange(/* not-defined-signal */, end).then(..)
compactRange().then(..) Vs. compactRange(options, callback)
compactRange(callback)
compactRange(options).then(..)
compactRange().then(..) |
I'd choose 5 if:
So at this time, I prefer option 2. That keeps the code simple (and easy to port to leveldown's friends): Lines 78 to 83 in 0e3cda4
|
Squash on merge. |
Closes #499.
The last commit (d54db39) (making
start
andend
optional) started as an exercise, to see how the nullish/empty logic translates tocompactRange
. Answer: it's counterintuitive.If, for symmetry with iterator range options, we cannot use a nullish
start
orend
, then it only leaves''
as "not defined" signal. On the C++ LevelDB side, it is the other way around. We can do 5 things:compactRange('', 'z', cb)
was already the case, thoughcompactRange(null, 'z', cb)
also worked (undocumented) and now it doesn't.compactRange(null, 'z', cb)
compacts first key to'z'
butiterator({ gte: null, lte: 'z' })
targets'null'
to'z'
.compactRange(null, 'z', cb)
targets the same range asiterator({ gte: null, lte: 'z' })
.null
, e.g.compactRange({ end: 'z' }, cb)
.