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 long |
maxTimeMS |
private MongoNamespace |
namespace |
private static FieldNameValidator |
NO_OP_FIELD_NAME_VALIDATOR |
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 void |
getMore(AsyncConnection connection,
ServerCursor cursor,
SingleResultCallback<java.util.List<T>> callback,
boolean tryNext) |
private void |
getMore(ServerCursor cursor,
SingleResultCallback<java.util.List<T>> callback,
boolean tryNext) |
(package private) ServerCursor |
getServerCursor() |
private void |
handleGetMoreQueryResult(AsyncConnection connection,
SingleResultCallback<java.util.List<T>> callback,
QueryResult<T> result,
boolean tryNext) |
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.
|
private void |
next(SingleResultCallback<java.util.List<T>> callback,
boolean tryNext) |
void |
setBatchSize(int batchSize)
Sets the batch size to use when requesting the next batch.
|
void |
tryNext(SingleResultCallback<java.util.List<T>> callback)
A special
next() case that returns the next batch if available or null. |
private static final FieldNameValidator NO_OP_FIELD_NAME_VALIDATOR
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 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 tryNext(SingleResultCallback<java.util.List<T>> callback)
AsyncBatchCursor
next()
case that returns the next batch if available or null.
Tailable cursors are an example where this is useful. A call to tryNext()
may return null, but in the future calling
tryNext()
would return a new batch if a document had been added to the capped collection.
tryNext
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 void next(SingleResultCallback<java.util.List<T>> callback, boolean tryNext)
private boolean limitReached()
private void getMore(ServerCursor cursor, SingleResultCallback<java.util.List<T>> callback, boolean tryNext)
private void getMore(AsyncConnection connection, ServerCursor cursor, SingleResultCallback<java.util.List<T>> callback, boolean tryNext)
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, boolean tryNext)
ServerCursor getServerCursor()