Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
/ memdown Public archive

Conversation

@MeirionHughes
Copy link
Member

No description provided.

@vweevers
Copy link
Member

Awesome!

@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.

@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.

@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]>
Co-Authored-By: Vincent Weevers <[email protected]>
@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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