-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
iterator issue #84
Comments
Hi! i think you used the for-loop in a "wrong" way. You put a Next()-call at the initializing position. Looking at the godoc for the for it.Rewind(); it.Valid(); it.Next() {
...
} So you can just put the Rewind()-call inside the head of the for-loop. Still wondering, why a new created iterator must be rewinded, following does not work too, if the Rewind()-call is missing: it.Rewind()
for it.Valid() {
kvItem = it.Item()
fmt.Println("k", string(kvItem.Key()), "v", string(kvItem.Value()), "c", kvItem.Counter())
it.Next()
} I would expect a new iterator is just usable after creating it. |
The reason In short, the reason to specify the initial point is that we do extra work in the background; and we need to know where to begin. Hope that answers your query. |
Well, the idea was to implement a custom Seek but as far as I understood it's not possible without calling Rewind. |
You can call |
Yes, but you can't build a Seek like Seek([]byte("contains")). You can only seek the whole key and that's my issue. I thought it would be possible to build a custom seek without Rewind. |
Hi there
I just started trying out badger and it seems very nice so far!
I'm not sure about the behavior of the iterator at one point.
I called TestWrite and then TestIterator. Without it.Rewind() before the loop you should encounter an error.
My question is pretty simple. Do I need to call rewind at this point or is it a bug?
The text was updated successfully, but these errors were encountered: