T
- the type of the distinct valuepublic class DistinctOperation<T> extends java.lang.Object implements AsyncReadOperation<AsyncBatchCursor<T>>, ReadOperation<BatchCursor<T>>
When possible, the distinct command uses an index to find documents and return values.
Modifier and Type | Field and Description |
---|---|
private Collation |
collation |
private Decoder<T> |
decoder |
private java.lang.String |
fieldName |
private BsonDocument |
filter |
private long |
maxTimeMS |
private MongoNamespace |
namespace |
private ReadConcern |
readConcern |
private static java.lang.String |
VALUES |
Constructor and Description |
---|
DistinctOperation(MongoNamespace namespace,
java.lang.String fieldName,
Decoder<T> decoder)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
private CommandOperationHelper.CommandTransformer<BsonDocument,AsyncBatchCursor<T>> |
asyncTransformer(ConnectionDescription connectionDescription) |
DistinctOperation<T> |
collation(Collation collation)
Sets the collation options
|
private Codec<BsonDocument> |
createCommandDecoder() |
private QueryResult<T> |
createQueryResult(BsonDocument result,
ConnectionDescription description) |
BatchCursor<T> |
execute(ReadBinding binding)
General execute which can return anything of type T
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<AsyncBatchCursor<T>> callback)
General execute which can return anything of type T
|
DistinctOperation<T> |
filter(BsonDocument filter)
Sets the query filter to apply to the query.
|
Collation |
getCollation()
Returns the collation options
|
private BsonDocument |
getCommand(SessionContext sessionContext) |
BsonDocument |
getFilter()
Gets the query filter.
|
long |
getMaxTime(java.util.concurrent.TimeUnit timeUnit)
Gets the maximum execution time on the server for this operation.
|
ReadConcern |
getReadConcern()
Gets the read concern
|
DistinctOperation<T> |
maxTime(long maxTime,
java.util.concurrent.TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
DistinctOperation<T> |
readConcern(ReadConcern readConcern)
Sets the read concern
|
private CommandOperationHelper.CommandTransformer<BsonDocument,BatchCursor<T>> |
transformer(ConnectionSource source,
Connection connection) |
private static final java.lang.String VALUES
private final MongoNamespace namespace
private final java.lang.String fieldName
private BsonDocument filter
private long maxTimeMS
private ReadConcern readConcern
private Collation collation
public DistinctOperation(MongoNamespace namespace, java.lang.String fieldName, Decoder<T> decoder)
namespace
- the database and collection namespace for the operation.fieldName
- the name of the field to return distinct values.decoder
- the decoder for the result documents.public BsonDocument getFilter()
public DistinctOperation<T> filter(BsonDocument filter)
filter
- the query filter, which may be null.public long getMaxTime(java.util.concurrent.TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic DistinctOperation<T> maxTime(long maxTime, java.util.concurrent.TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic ReadConcern getReadConcern()
public DistinctOperation<T> readConcern(ReadConcern readConcern)
readConcern
- the read concernpublic Collation getCollation()
public DistinctOperation<T> collation(Collation collation)
A null value represents the server default.
collation
- the collation options to usepublic BatchCursor<T> execute(ReadBinding binding)
ReadOperation
execute
in interface ReadOperation<BatchCursor<T>>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<AsyncBatchCursor<T>> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<AsyncBatchCursor<T>>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executedprivate Codec<BsonDocument> createCommandDecoder()
private QueryResult<T> createQueryResult(BsonDocument result, ConnectionDescription description)
private CommandOperationHelper.CommandTransformer<BsonDocument,BatchCursor<T>> transformer(ConnectionSource source, Connection connection)
private CommandOperationHelper.CommandTransformer<BsonDocument,AsyncBatchCursor<T>> asyncTransformer(ConnectionDescription connectionDescription)
private BsonDocument getCommand(SessionContext sessionContext)