Skip to content
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

feat: implement _seek #184

Merged
merged 2 commits into from
Jun 27, 2019
Merged

feat: implement _seek #184

merged 2 commits into from
Jun 27, 2019

Conversation

MeirionHughes
Copy link
Member

No description provided.

@vweevers
Copy link
Member

Awesome!

memdown.js Outdated Show resolved Hide resolved
@vweevers
Copy link
Member

abstract-leveldown has tests for this, which can (should) be enabled here:

seek: false

@MeirionHughes
Copy link
Member Author

eek, yeah activating that broke it. :/

@MeirionHughes
Copy link
Member Author

... that was more painful that I was hoping for.

anyway; its not quite like leveldb as I think that puts the iterator on either side of the table and its marked as in invalid. For memdown I've had to make this._tree undefined and a test on _next to signify the iterator is invalid for a given range and target. Tests should (hopefully) be passing now at least.

memdown.js Outdated Show resolved Hide resolved
@vweevers
Copy link
Member

its not quite like leveldb as I think that puts the iterator on either side of the table and its marked as in invalid. For memdown I've had to make this._tree undefined and a test on _next to signify the iterator is invalid for a given range and target. Tests should (hopefully) be passing now at least.

What happens when you do two subsequent seeks to different targets (and the second target is in range)? I don't remember if that's valid in leveldown or not.

@vweevers
Copy link
Member

cc @peakji, our seek expert

@MeirionHughes
Copy link
Member Author

in principle a new seek should be fine (in memdown) as it goes back to the rgb tree to start fresh. I can add a test tomorrow if there isn't one already.

@MeirionHughes
Copy link
Member Author

MeirionHughes commented Jun 20, 2019

also a bit concerned that the seek tests from abstract level iterator don't seem to fail for my code, which no longer converts strings to buffers (if asBuffer or keysAsBuffer is set) before comparing keys. either memdown puts all keys as strings, or the tests are not covering the case where you put buffers keys, but seek a target with a string.

@vweevers
Copy link
Member

or the tests are not covering the case where you put buffers as keys, but seek a target with a string

yes, that's the case

@peakji
Copy link
Member

peakji commented Jun 21, 2019

What happens when you do two subsequent seeks to different targets (and the second target is in range)? I don't remember if that's valid in leveldown or not.

It is fine to seek() multiple times without doing next() in leveldown, the underlying dbIterator is valid as long as the source contains an entry that comes at or past target.

@vweevers
Copy link
Member

vweevers commented Jun 21, 2019

Re: buffer vs string targets, keyAsBuffer is not relevant there, because that option only pertains to output (whether you want to yield buffer or string keys). Converting the target to a string won't work if you've stored Buffer keys. And vice versa.

So assuming that we're gonna go with the IDB-style comparator (sort by type, which means buffers are never equal to strings, unlike in leveldown), then I think the best course of action is to update the abstract-leveldown buffer seek test to operate on a buffer data set. In other words, the type of the target must match the type of stored keys.

memdown.js Outdated Show resolved Hide resolved
test.js Outdated Show resolved Hide resolved
@vweevers
Copy link
Member

@peakji @ralphtheninja Seeing as both @MeirionHughes and I wrote code here, could you review?

@vweevers vweevers added enhancement New feature or request semver-minor New features that are backward compatible labels Jun 21, 2019
@MeirionHughes
Copy link
Member Author

MeirionHughes commented Jun 21, 2019

need to check can seek immediately after creating iterator its fine. I've squashed the commits.

Co-Authored-By: Vincent Weevers <[email protected]>
memdown.js Show resolved Hide resolved
Co-Authored-By: Vincent Weevers <[email protected]>
test.js Show resolved Hide resolved
@MeirionHughes
Copy link
Member Author

Just waiting on another review before this be merged?

@vweevers
Copy link
Member

Just waiting on another review before this be merged?

I was hoping for it but it's been long enough and we've got 100% coverage. Will release tomorrow

@vweevers vweevers merged commit 0b30a4f into Level:master Jun 27, 2019
@MeirionHughes
Copy link
Member Author

cool thanks. 👍

@vweevers
Copy link
Member

4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-minor New features that are backward compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants