use of com.mongodb.client.model.CountOptions in project core-ng-project by neowu.
the class MongoCollectionImpl method count.
@Override
public long count(Count count) {
StopWatch watch = new StopWatch();
Bson filter = count.filter == null ? new BsonDocument() : count.filter;
try {
return collection(count.readPreference).count(filter, new CountOptions().maxTime(mongo.timeoutInMs, TimeUnit.MILLISECONDS));
} finally {
long elapsedTime = watch.elapsedTime();
ActionLogContext.track("mongoDB", elapsedTime, 1, 0);
logger.debug("count, collection={}, filter={}, readPref={}, elapsedTime={}", collectionName, new BsonParam(filter, mongo.registry), count.readPreference == null ? null : count.readPreference.getName(), elapsedTime);
checkSlowOperation(elapsedTime);
}
}
use of com.mongodb.client.model.CountOptions in project jphp by jphp-compiler.
the class CountOptionsMemoryOperation method convert.
@Override
public CountOptions convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
if (arg.isNull())
return null;
ArrayMemory arr = arg.toValue(ArrayMemory.class);
CountOptions options = new CountOptions();
if (arr.containsKey("skip"))
options.skip(arg.valueOfIndex("skip").toInteger());
if (arr.containsKey("limit"))
options.limit(arg.valueOfIndex("limit").toInteger());
if (arr.containsKey("maxTime")) {
options.maxTime(WrapTimer.parsePeriod(arg.valueOfIndex("maxTime").toString()), TimeUnit.MILLISECONDS);
}
return options;
}
Aggregations