public class DistinctOperation extends Object implements AsyncReadOperation<BsonArray>, ReadOperation<BsonArray>
When possible, the distinct command uses an index to find documents and return values.
Constructor and Description |
---|
DistinctOperation(MongoNamespace namespace,
String fieldName)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
BsonArray |
execute(ReadBinding binding)
General execute which can return anything of type T
|
void |
executeAsync(AsyncReadBinding binding,
SingleResultCallback<BsonArray> callback)
General execute which can return anything of type T
|
DistinctOperation |
filter(BsonDocument filter)
Sets the query filter to apply to the query.
|
BsonDocument |
getFilter()
Gets the query filter.
|
long |
getMaxTime(TimeUnit timeUnit)
Gets the maximum execution time on the server for this operation.
|
DistinctOperation |
maxTime(long maxTime,
TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.
|
public DistinctOperation(MongoNamespace namespace, String fieldName)
namespace
- the database and collection namespace for the operation.fieldName
- the name of the field to return distinct values.public BsonDocument getFilter()
public DistinctOperation filter(BsonDocument filter)
filter
- the query filter, which may be null.public long getMaxTime(TimeUnit timeUnit)
timeUnit
- the time unit to return the result inpublic DistinctOperation maxTime(long maxTime, TimeUnit timeUnit)
maxTime
- the max timetimeUnit
- the time unit, which may not be nullpublic BsonArray execute(ReadBinding binding)
ReadOperation
execute
in interface ReadOperation<BsonArray>
binding
- the binding to execute in the context ofpublic void executeAsync(AsyncReadBinding binding, SingleResultCallback<BsonArray> callback)
AsyncReadOperation
executeAsync
in interface AsyncReadOperation<BsonArray>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executed