class QueryBatchCursor<T> extends java.lang.Object implements BatchCursor<T>
| Modifier and Type | Field and Description |
|---|---|
private int |
batchSize |
private boolean |
closed |
private ConnectionSource |
connectionSource |
private int |
count |
private Decoder<T> |
decoder |
private int |
limit |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
private java.util.List<T> |
nextBatch |
private ServerCursor |
serverCursor |
| Constructor and Description |
|---|
QueryBatchCursor(QueryResult<T> firstQueryResult,
int limit,
int batchSize,
Decoder<T> decoder) |
QueryBatchCursor(QueryResult<T> firstQueryResult,
int limit,
int batchSize,
Decoder<T> decoder,
ConnectionSource connectionSource) |
QueryBatchCursor(QueryResult<T> firstQueryResult,
int limit,
int batchSize,
long maxTimeMS,
Decoder<T> decoder,
ConnectionSource connectionSource,
Connection connection) |
| Modifier and Type | Method and Description |
|---|---|
private BsonDocument |
asGetMoreCommandDocument() |
void |
close() |
int |
getBatchSize()
Gets the batch size to use when requesting the next batch.
|
private void |
getMore() |
ServerAddress |
getServerAddress()
Returns the server address
|
ServerCursor |
getServerCursor()
Returns the server cursor
|
boolean |
hasNext()
Returns true if another batch of results exists.
|
private void |
initFromCommandResult(BsonDocument getMoreCommandResultDocument) |
private void |
initFromQueryResult(QueryResult<T> queryResult) |
private void |
killCursor() |
private void |
killCursor(Connection connection) |
private boolean |
limitReached() |
java.util.List<T> |
next()
Returns the next batch of results.
|
void |
remove() |
void |
setBatchSize(int batchSize)
Sets the batch size to use when requesting the next batch.
|
(package private) boolean |
tryHasNext() |
java.util.List<T> |
tryNext()
A special
next() case that returns the next batch if available or null. |
private final MongoNamespace namespace
private final int limit
private final ConnectionSource connectionSource
private final long maxTimeMS
private int batchSize
private ServerCursor serverCursor
private java.util.List<T> nextBatch
private int count
private boolean closed
QueryBatchCursor(QueryResult<T> firstQueryResult, int limit, int batchSize, Decoder<T> decoder)
QueryBatchCursor(QueryResult<T> firstQueryResult, int limit, int batchSize, Decoder<T> decoder, ConnectionSource connectionSource)
QueryBatchCursor(QueryResult<T> firstQueryResult, int limit, int batchSize, long maxTimeMS, Decoder<T> decoder, ConnectionSource connectionSource, Connection connection)
public boolean hasNext()
BatchCursorhasNext in interface BatchCursor<T>hasNext in interface java.util.Iterator<java.util.List<T>>public java.util.List<T> next()
BatchCursornext in interface BatchCursor<T>next in interface java.util.Iterator<java.util.List<T>>public void setBatchSize(int batchSize)
BatchCursorsetBatchSize in interface BatchCursor<T>batchSize - the non-negative batch size. 0 means to use the server default.public int getBatchSize()
BatchCursorgetBatchSize in interface BatchCursor<T>public void remove()
remove in interface java.util.Iterator<java.util.List<T>>public void close()
close in interface BatchCursor<T>close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic java.util.List<T> tryNext()
BatchCursornext() 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 BatchCursor<T>boolean tryHasNext()
public ServerCursor getServerCursor()
BatchCursorgetServerCursor in interface BatchCursor<T>public ServerAddress getServerAddress()
BatchCursorgetServerAddress in interface BatchCursor<T>private void getMore()
private BsonDocument asGetMoreCommandDocument()
private void initFromQueryResult(QueryResult<T> queryResult)
private void initFromCommandResult(BsonDocument getMoreCommandResultDocument)
private boolean limitReached()
private void killCursor()
private void killCursor(Connection connection)