final class AsyncChangeStreamBatchCursor<T> extends java.lang.Object implements AsyncBatchCursor<T>
Modifier and Type | Class and Description |
---|---|
private static interface |
AsyncChangeStreamBatchCursor.AsyncBlock |
Modifier and Type | Field and Description |
---|---|
private AsyncReadBinding |
binding |
private ChangeStreamOperation<T> |
changeStreamOperation |
private BsonDocument |
resumeToken |
private AsyncBatchCursor<RawBsonDocument> |
wrapped |
Constructor and Description |
---|
AsyncChangeStreamBatchCursor(ChangeStreamOperation<T> changeStreamOperation,
AsyncBatchCursor<RawBsonDocument> wrapped,
AsyncReadBinding binding) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
private SingleResultCallback<java.util.List<RawBsonDocument>> |
convertResultsCallback(SingleResultCallback<java.util.List<T>> callback) |
int |
getBatchSize()
Gets the batch size to use when requesting the next batch.
|
(package private) AsyncBatchCursor<RawBsonDocument> |
getWrapped() |
boolean |
isClosed()
Return true if the AsyncBatchCursor has been closed
|
void |
next(SingleResultCallback<java.util.List<T>> callback)
Returns the next batch of results.
|
private void |
resumeableOperation(AsyncChangeStreamBatchCursor.AsyncBlock asyncBlock,
SingleResultCallback<java.util.List<RawBsonDocument>> callback) |
private void |
retryOperation(AsyncChangeStreamBatchCursor.AsyncBlock asyncBlock,
SingleResultCallback<java.util.List<RawBsonDocument>> callback) |
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 final AsyncReadBinding binding
private final ChangeStreamOperation<T> changeStreamOperation
private volatile BsonDocument resumeToken
private volatile AsyncBatchCursor<RawBsonDocument> wrapped
AsyncChangeStreamBatchCursor(ChangeStreamOperation<T> changeStreamOperation, AsyncBatchCursor<RawBsonDocument> wrapped, AsyncReadBinding binding)
AsyncBatchCursor<RawBsonDocument> getWrapped()
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>
public void close()
close
in interface AsyncBatchCursor<T>
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
private void resumeableOperation(AsyncChangeStreamBatchCursor.AsyncBlock asyncBlock, SingleResultCallback<java.util.List<RawBsonDocument>> callback)
private void retryOperation(AsyncChangeStreamBatchCursor.AsyncBlock asyncBlock, SingleResultCallback<java.util.List<RawBsonDocument>> callback)
private SingleResultCallback<java.util.List<RawBsonDocument>> convertResultsCallback(SingleResultCallback<java.util.List<T>> callback)