final class FindIterableImpl<TDocument,TResult> extends java.lang.Object implements FindIterable<TResult>
Modifier and Type | Class and Description |
---|---|
private class |
FindIterableImpl.FindOperationIterable |
Modifier and Type | Field and Description |
---|---|
private CodecRegistry |
codecRegistry |
private java.lang.Class<TDocument> |
documentClass |
private OperationExecutor |
executor |
private Bson |
filter |
private FindOptions |
findOptions |
private MongoNamespace |
namespace |
private ReadConcern |
readConcern |
private ReadPreference |
readPreference |
private java.lang.Class<TResult> |
resultClass |
Constructor and Description |
---|
FindIterableImpl(MongoNamespace namespace,
java.lang.Class<TDocument> documentClass,
java.lang.Class<TResult> resultClass,
CodecRegistry codecRegistry,
ReadPreference readPreference,
ReadConcern readConcern,
OperationExecutor executor,
Bson filter,
FindOptions findOptions) |
Modifier and Type | Method and Description |
---|---|
FindIterable<TResult> |
batchSize(int batchSize)
Sets the number of documents to return per batch.
|
FindIterable<TResult> |
collation(Collation collation)
Sets the collation options
|
FindIterable<TResult> |
comment(java.lang.String comment)
Sets the comment to the query.
|
private FindOperation<TResult> |
createQueryOperation() |
FindIterable<TResult> |
cursorType(CursorType cursorType)
Sets the cursor type.
|
private MongoIterable<TResult> |
execute() |
FindIterable<TResult> |
filter(Bson filter)
Sets the query filter to apply to the query.
|
TResult |
first()
Helper to return the first item in the iterator or null.
|
void |
forEach(Block<? super TResult> block)
Iterates over all documents in the view, applying the given block to each.
|
FindIterable<TResult> |
hint(Bson hint)
Sets the hint for which index to use.
|
<A extends java.util.Collection<? super TResult>> |
into(A target)
Iterates over all the documents, adding each to the given target.
|
MongoCursor<TResult> |
iterator() |
FindIterable<TResult> |
limit(int limit)
Sets the limit to apply.
|
<U> MongoIterable<U> |
map(Function<TResult,U> mapper)
Maps this iterable from the source document type to the target document type.
|
FindIterable<TResult> |
max(Bson max)
Sets the exclusive upper bound for a specific index.
|
FindIterable<TResult> |
maxAwaitTime(long maxAwaitTime,
java.util.concurrent.TimeUnit timeUnit)
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor
query.
|
FindIterable<TResult> |
maxScan(long maxScan)
Sets the maximum number of documents or index keys to scan when executing the query.
|
FindIterable<TResult> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
FindIterable<TResult> |
min(Bson min)
Sets the minimum inclusive lower bound for a specific index.
|
FindIterable<TResult> |
modifiers(Bson modifiers)
Sets the query modifiers to apply to this operation.
|
FindIterable<TResult> |
noCursorTimeout(boolean noCursorTimeout)
The server normally times out idle cursors after an inactivity period (10 minutes)
to prevent excess memory use.
|
FindIterable<TResult> |
oplogReplay(boolean oplogReplay)
Users should not set this under normal circumstances.
|
FindIterable<TResult> |
partial(boolean partial)
Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
|
FindIterable<TResult> |
projection(Bson projection)
Sets a document describing the fields to return for all matching documents.
|
FindIterable<TResult> |
returnKey(boolean returnKey)
Sets the returnKey.
|
FindIterable<TResult> |
showRecordId(boolean showRecordId)
Sets the showRecordId.
|
FindIterable<TResult> |
skip(int skip)
Sets the number of documents to skip.
|
FindIterable<TResult> |
snapshot(boolean snapshot)
Sets the snapshot.
|
FindIterable<TResult> |
sort(Bson sort)
Sets the sort criteria to apply to the query.
|
private BsonDocument |
toBsonDocument(Bson document) |
private final MongoNamespace namespace
private final java.lang.Class<TDocument> documentClass
private final java.lang.Class<TResult> resultClass
private final ReadPreference readPreference
private final ReadConcern readConcern
private final CodecRegistry codecRegistry
private final OperationExecutor executor
private final FindOptions findOptions
private Bson filter
FindIterableImpl(MongoNamespace namespace, java.lang.Class<TDocument> documentClass, java.lang.Class<TResult> resultClass, CodecRegistry codecRegistry, ReadPreference readPreference, ReadConcern readConcern, OperationExecutor executor, Bson filter, FindOptions findOptions)
public FindIterable<TResult> filter(Bson filter)
FindIterable
filter
in interface FindIterable<TResult>
filter
- the filter, which may be null.public FindIterable<TResult> limit(int limit)
FindIterable
limit
in interface FindIterable<TResult>
limit
- the limit, which may be nullpublic FindIterable<TResult> skip(int skip)
FindIterable
skip
in interface FindIterable<TResult>
skip
- the number of documents to skippublic FindIterable<TResult> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
FindIterable
maxTime
in interface FindIterable<TResult>
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic FindIterable<TResult> maxAwaitTime(long maxAwaitTime, java.util.concurrent.TimeUnit timeUnit)
FindIterable
maxAwaitTime
in interface FindIterable<TResult>
maxAwaitTime
- the max await timetimeUnit
- the time unit to return the result inpublic FindIterable<TResult> batchSize(int batchSize)
FindIterable
batchSize
in interface FindIterable<TResult>
batchSize
in interface MongoIterable<TResult>
batchSize
- the batch sizepublic FindIterable<TResult> collation(Collation collation)
FindIterable
A null value represents the server default.
collation
in interface FindIterable<TResult>
collation
- the collation options to usepublic FindIterable<TResult> modifiers(Bson modifiers)
FindIterable
modifiers
in interface FindIterable<TResult>
modifiers
- the query modifiers to apply, which may be null.public FindIterable<TResult> projection(Bson projection)
FindIterable
projection
in interface FindIterable<TResult>
projection
- the project document, which may be null.public FindIterable<TResult> sort(Bson sort)
FindIterable
sort
in interface FindIterable<TResult>
sort
- the sort criteria, which may be null.public FindIterable<TResult> noCursorTimeout(boolean noCursorTimeout)
FindIterable
noCursorTimeout
in interface FindIterable<TResult>
noCursorTimeout
- true if cursor timeout is disabledpublic FindIterable<TResult> oplogReplay(boolean oplogReplay)
FindIterable
oplogReplay
in interface FindIterable<TResult>
oplogReplay
- if oplog replay is enabledpublic FindIterable<TResult> partial(boolean partial)
FindIterable
partial
in interface FindIterable<TResult>
partial
- if partial results for sharded clusters is enabledpublic FindIterable<TResult> cursorType(CursorType cursorType)
FindIterable
cursorType
in interface FindIterable<TResult>
cursorType
- the cursor typepublic FindIterable<TResult> comment(java.lang.String comment)
FindIterable
comment
in interface FindIterable<TResult>
comment
- the commentpublic FindIterable<TResult> hint(Bson hint)
FindIterable
hint
in interface FindIterable<TResult>
hint
- the hintpublic FindIterable<TResult> max(Bson max)
FindIterable
max
in interface FindIterable<TResult>
max
- the maxpublic FindIterable<TResult> min(Bson min)
FindIterable
min
in interface FindIterable<TResult>
min
- the minpublic FindIterable<TResult> maxScan(long maxScan)
FindIterable
maxScan
in interface FindIterable<TResult>
maxScan
- the maxScanpublic FindIterable<TResult> returnKey(boolean returnKey)
FindIterable
returnKey
in interface FindIterable<TResult>
returnKey
- the returnKeypublic FindIterable<TResult> showRecordId(boolean showRecordId)
FindIterable
$recordId
to the returned documents.showRecordId
in interface FindIterable<TResult>
showRecordId
- the showRecordIdpublic FindIterable<TResult> snapshot(boolean snapshot)
FindIterable
snapshot
in interface FindIterable<TResult>
snapshot
- the snapshotpublic MongoCursor<TResult> iterator()
iterator
in interface MongoIterable<TResult>
iterator
in interface java.lang.Iterable<TResult>
public TResult first()
MongoIterable
first
in interface MongoIterable<TResult>
public <U> MongoIterable<U> map(Function<TResult,U> mapper)
MongoIterable
map
in interface MongoIterable<TResult>
U
- the target document typemapper
- a function that maps from the source to the target document typepublic void forEach(Block<? super TResult> block)
MongoIterable
Similar to map
but the function is fully encapsulated with no returned result.
forEach
in interface MongoIterable<TResult>
block
- the block to apply to each document of type T.public <A extends java.util.Collection<? super TResult>> A into(A target)
MongoIterable
into
in interface MongoIterable<TResult>
A
- the collection typetarget
- the collection to insert intoprivate MongoIterable<TResult> execute()
private FindOperation<TResult> createQueryOperation()
private BsonDocument toBsonDocument(Bson document)