summaryrefslogtreecommitdiff
path: root/src/mongo/shell/bench.cpp
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2016-05-04 14:10:38 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2016-05-06 17:19:05 -0400
commitdc5f741da617060e4531a1fe7ca7f110735ac2ee (patch)
tree4aa57a27e3be665e8dd03051377b6eb0c72eea49 /src/mongo/shell/bench.cpp
parent32d272af6b8fea1bbbe477c28e1cd8a61f136da4 (diff)
downloadmongo-dc5f741da617060e4531a1fe7ca7f110735ac2ee.tar.gz
SERVER-24045 Refactor LiteParsedQuery
Diffstat (limited to 'src/mongo/shell/bench.cpp')
-rw-r--r--src/mongo/shell/bench.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index 83a40033eeb..ae9c7b093d9 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -713,19 +713,13 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
BSONObj fixedQuery = fixQuery(op.query, bsonTemplateEvaluator);
BSONObj result;
if (op.useReadCmd) {
- unique_ptr<LiteParsedQuery> lpq =
- LiteParsedQuery::makeAsFindCmd(NamespaceString(op.ns),
- fixedQuery,
- op.projection, // projection
- BSONObj(), // sort
- BSONObj(), // hint
- BSONObj(), // readConcern
- BSONObj(), // collation
- boost::none, // skip
- 1LL, // limit
- boost::none, // batchSize
- boost::none, // ntoreturn
- false); // wantMore
+ auto lpq = stdx::make_unique<LiteParsedQuery>(NamespaceString(op.ns));
+ lpq->setFilter(fixedQuery);
+ lpq->setProj(op.projection);
+ lpq->setLimit(1LL);
+ lpq->setWantMore(false);
+ invariantOK(lpq->validate());
+
BenchRunEventTrace _bret(&stats.findOneCounter);
runQueryWithReadCommands(conn, std::move(lpq), &result);
} else {
@@ -820,18 +814,21 @@ void BenchRunWorker::generateLoadOnConnection(DBClientBase* conn) {
uassert(28824,
"cannot use 'options' in combination with read commands",
!op.options);
- unique_ptr<LiteParsedQuery> lpq = LiteParsedQuery::makeAsFindCmd(
- NamespaceString(op.ns),
- fixedQuery,
- op.projection,
- BSONObj(), // sort
- BSONObj(), // hint
- BSONObj(), // readConcern
- BSONObj(), // collation
- op.skip ? boost::optional<long long>(op.skip) : boost::none,
- op.limit ? boost::optional<long long>(op.limit) : boost::none,
- op.batchSize ? boost::optional<long long>(op.batchSize)
- : boost::none);
+
+ auto lpq = stdx::make_unique<LiteParsedQuery>(NamespaceString(op.ns));
+ lpq->setFilter(fixedQuery);
+ lpq->setProj(op.projection);
+ if (op.skip) {
+ lpq->setSkip(op.skip);
+ }
+ if (op.limit) {
+ lpq->setLimit(op.limit);
+ }
+ if (op.batchSize) {
+ lpq->setBatchSize(op.batchSize);
+ }
+ invariantOK(lpq->validate());
+
BenchRunEventTrace _bret(&stats.queryCounter);
count = runQueryWithReadCommands(conn, std::move(lpq));
} else {