question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid Reverse Iterator Seek Test

See original GitHub issue

It seems the test for iterator#seek() on reverse iterator is invalid. This test uses make which batches three items with keys one, two, three, then creates an iterator with { reverse: true, limit: 1 }, then attempts to seek to key three! expecting to find it and for the key to be three.

Possibly invalid assumptions:

  1. Items are stored in the order they are received: { reverse: true, limit: 1 }
  2. Key seeking is done by subset matching: three! != three but does start with three

Possible changes:

  1. Remove { limit: 1 } to seek all items in reverse and tolerate the subset match
  2. Correct the seek('three!') call to be seek('three')

If both changes are made then this test passes. Am I missing some reason why this is a valid test?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vweeverscommented, Dec 6, 2019

The limit applies to the total number of items retrieved, not to what’s on disk. It does a seek first, then from it where landed, retrieves items until the limit is reached.

1reaction
GioCirquecommented, Dec 6, 2019

Ahhh, I see now. Thank you for that explanation. This might be a good explanation to add to the iterator documentation? I’ll close this issue. Sorry for the trouble.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seek iterator with Reverse doesn't work · Issue #436 - GitHub
My code was incorrect in this case, and to be truly correct you would need to know the length of the longest key...
Read more >
How can I check that assignment of const_reverse_iterator to ...
I can check that assignment of iterator{} = const_iterator{} is not valid, but not an assignment of reverse_iterator{} ...
Read more >
Iterator Invalidation in C++ - GeeksforGeeks
All iterators and references are invalidated unless the inserted member is at an end (front or back) of the deque (in which case...
Read more >
Java - While vs For vs Iterator Performance Test - Mkyong.com
A simple Java code to test the performance of the following looping methods : While Loop; For Loop; Iterator Loop.
Read more >
How to Remove Objects From ArrayList while Iterating in Java
Now, let's see an example of removing elements from ArrayList while looping using for() loop and ArrayList.remove() method, which is wrong, and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found