class AsyncQueryBatchCursor<T> extends java.lang.Object implements AsyncBatchCursor<T>
Modifier and Type | Class and Description |
---|---|
private class |
AsyncQueryBatchCursor.CommandResultSingleResultCallback |
private class |
AsyncQueryBatchCursor.QueryResultSingleResultCallback |
Modifier and Type | Field and Description |
---|---|
private int |
batchSize |
private AsyncConnectionSource |
connectionSource |
private int |
count |
private java.util.concurrent.atomic.AtomicReference<ServerCursor> |
cursor |
private Decoder<T> |
decoder |
private QueryResult<T> |
firstBatch |
private java.util.concurrent.atomic.AtomicBoolean |
isClosed |
private int |
limit |
private java.lang.Object |
lock |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
Constructor and Description |
---|
AsyncQueryBatchCursor(QueryResult<T> firstBatch,
int limit,
int batchSize,
long maxTimeMS,
Decoder<T> decoder,
AsyncConnectionSource connectionSource,
AsyncConnection connection) |
Modifier and Type | Method and Description |
---|---|
private BsonDocument |
asGetMoreCommandDocument(long cursorId) |
private BsonDocument |
asKillCursorsCommandDocument(ServerCursor localCursor) |
void |
close() |
int |
getBatchSize()
Gets the batch size to use when requesting the next batch.
|
private ServerCursor |
getCursorForKillCursorOnClose() |
private ServerCursor |
getCursorForNext() |
private void |
getMore(AsyncConnection connection,
ServerCursor cursor,
SingleResultCallback<java.util.List<T>> callback) |
private void |
getMore(ServerCursor cursor,
SingleResultCallback<java.util.List<T>> callback) |
private void |
handleGetMoreQueryResult(AsyncConnection connection,
SingleResultCallback<java.util.List<T>> callback,
QueryResult<T> result) |
boolean |
isClosed()
Return true if the AsyncBatchCursor has been closed
|
private void |
killCursor(AsyncConnection connection) |
private void |
killCursorAsynchronouslyAndReleaseConnectionAndSource(AsyncConnection connection,
ServerCursor localCursor) |
private void |
killCursorOnClose() |
private boolean |
limitReached() |
void |
next(SingleResultCallback<java.util.List<T>> callback)
Returns the next batch of results.
|
void |
setBatchSize(int batchSize)
Sets the batch size to use when requesting the next batch.
|
private final MongoNamespace namespace
private final int limit
private final long maxTimeMS
private final AsyncConnectionSource connectionSource
private final java.util.concurrent.atomic.AtomicBoolean isClosed
private final java.util.concurrent.atomic.AtomicReference<ServerCursor> cursor
private final java.lang.Object lock
private volatile QueryResult<T> firstBatch
private volatile int batchSize
private volatile int count
AsyncQueryBatchCursor(QueryResult<T> firstBatch, int limit, int batchSize, long maxTimeMS, Decoder<T> decoder, AsyncConnectionSource connectionSource, AsyncConnection connection)
public void close()
close
in interface AsyncBatchCursor<T>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void next(SingleResultCallback<java.util.List<T>> callback)
AsyncBatchCursor
next
in interface AsyncBatchCursor<T>
callback
- callback to receive the next batch of resultspublic void setBatchSize(int batchSize)
AsyncBatchCursor
setBatchSize
in interface AsyncBatchCursor<T>
batchSize
- the non-negative batch size. 0 means to use the server default.public int getBatchSize()
AsyncBatchCursor
getBatchSize
in interface AsyncBatchCursor<T>
public boolean isClosed()
AsyncBatchCursor
isClosed
in interface AsyncBatchCursor<T>
private boolean limitReached()
private void getMore(ServerCursor cursor, SingleResultCallback<java.util.List<T>> callback)
private void getMore(AsyncConnection connection, ServerCursor cursor, SingleResultCallback<java.util.List<T>> callback)
private BsonDocument asGetMoreCommandDocument(long cursorId)
private void killCursorOnClose()
private void killCursor(AsyncConnection connection)
private void killCursorAsynchronouslyAndReleaseConnectionAndSource(AsyncConnection connection, ServerCursor localCursor)
private BsonDocument asKillCursorsCommandDocument(ServerCursor localCursor)
private void handleGetMoreQueryResult(AsyncConnection connection, SingleResultCallback<java.util.List<T>> callback, QueryResult<T> result)
private ServerCursor getCursorForNext()
private ServerCursor getCursorForKillCursorOnClose()