[JAVA-515] Rewind for a DBCursor Created: 02/Feb/12 Updated: 25/Jun/13 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Trivial - P5 |
| Reporter: | Uladzimir Mihura | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | epam | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
There is no way to rewind cursor in Java. At the same time other languages supports this: |
| Comments |
| Comment by Jeffrey Yemin [ 25/Jun/13 ] | |||||||||||||||
|
In 3.0, calling iterator() will return a cursor object. | |||||||||||||||
| Comment by Scott Hernandez (Inactive) [ 02/Feb/12 ] | |||||||||||||||
|
If anything that seems more confusing. Adding a reset() makes sense in this respect across the boards. For java the current functionality is very java collection like. It is a little confusing because there is an implicit iterator on DBCursor itself, because it implement next/hasNext(). To do what you want you would need to do something like this:
| |||||||||||||||
| Comment by Uladzimir Mihura [ 02/Feb/12 ] | |||||||||||||||
|
Thank you Jeff, I just want to make driver more developer friendly and standardized. For example I need to output 3 records and reset cursor to it's original state.
How it can be
In Python and PHP rewind leads to reseting all properties of a cursor, even skip and limit. -vova | |||||||||||||||
| Comment by Jeffrey Yemin [ 02/Feb/12 ] | |||||||||||||||
So every time you iterate the cursor with new for loop syntax (which will call this method), it creates a copy of the DBCursor, thus resetting it to start at the beginning. | |||||||||||||||
| Comment by Uladzimir Mihura [ 02/Feb/12 ] | |||||||||||||||
|
So I'm a bit confused. Please, consider the following code:
Results to:
-vova | |||||||||||||||
| Comment by Scott Hernandez (Inactive) [ 02/Feb/12 ] | |||||||||||||||
|
In java this is done with an iterator implicitly (or explicitly):
|