[JAVA-1326] Introduce API for tailable cursors that doesn't break Iterator contract Created: 31/Jul/14  Updated: 31/Mar/15  Resolved: 07/Oct/14

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: 3.0.0

Type: New Feature Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Ross Lawley
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-1179 In order to build a tailable cursor, ... Closed
Related
is related to JAVA-1255 Add DBCursor.tryNext() method for tai... Closed

 Description   

Current proposal is something like this:

public interface TailableCursor<T> extends MongoCursor<T> {
    /** 
        Move to the next document if available, otherwise return null.
    */
    T tryNext();
}

Normal usage would just use the existing MongoCursor interface (which extends Iterator and adds a close() method), but for users that don't want to block waiting for the next document, the non-blocking tryNext() method can be used, e.g.

    while (true) {
         Document doc = cursor.tryNext();
         // do other useful work here
    }



 Comments   
Comment by Jeffrey Yemin [ 31/Mar/15 ]

Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.

Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Cleaner tryNext() implementation for MongoCursors

JAVA-1326
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f4ae1f53605e09c9cc94f95fd652503a3dc6f0ac

Comment by Githook User [ 07/Oct/14 ]

Author:

{u'username': u'rozza', u'name': u'Ross Lawley', u'email': u'ross.lawley@gmail.com'}

Message: Cleaner tryNext() implementation for MongoCursors

JAVA-1326
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/f4ae1f53605e09c9cc94f95fd652503a3dc6f0ac

Generated at Thu Feb 08 08:54:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.