improve CursorIterator
See original GitHub issueConsider making CursorIterator
more extensible. It would be reasonable to be able to subclass to provide a range iterator (i.e. a forward iterator that checks an upper bound key, or a reverse iterator checking a lower bound). Since the class is final and tryToComputeNext
is private, this is not currently feasible.
Another minor point is that the state machine should probably include a CLOSED
state (in which hasNext
returns false, and repeated calls to close
are idempotent).
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Iterators vs. Cursors: A Case Study in Objects vs. Values
The improvement requires recoding but is incremental in cost, because the code for cursors and iterators is very similar. To benefit from cursors,...
Read more >design patterns - How to implement a cursor iterator?
The correct approach for the cursor is option 2. The answer is already in your quote, which describes option 2:.
Read more >Cursor vs Iterator pattern - c++ - Stack Overflow
The Cursor pattern you described is the combination of two patterns: Proxy and Iterator. The reason the standard library is different is to...
Read more >Iterate over Query Result Sets Using a Cursor - Navicat
Like WHILE loops, cursors allow programmers to process each row of a SELECT result set individually by iterating over them. While many SQL ......
Read more >Iterators in Java - GeeksforGeeks
A Java Cursor is an Iterator, which is used to iterate or traverse or retrieve a Collection or Stream object's elements one by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just pushed the final commits. LmdbJava now supports every range type offered by Guava (in both forward and backward cursor directions) and method names now reflect its terminology. There is also an example of using a Guava comparator, plus I added Guava to the
ComparatorTest
to further validate the project’s comparators against third-party references. Are we happy to close this ticket?I too found the names unclear, which is why I put examples in the
KeyRangeType
JavaDocs. I intend to add some moreKeyRangeType
values to cover the exclusive cases.Users can provide their own
Comparator
by invokingCursorIterator<T> Dbi.iterate(Txn<T>, KeyRange<T>, Comparator<T>)
. Is that sufficient?Good idea. I’ll tackle that tomorrow.