summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/client/SConscript21
-rw-r--r--src/mongo/client/dbclient.cpp147
-rw-r--r--src/mongo/client/dbclientinterface.h144
-rw-r--r--src/mongo/client/query.cpp189
-rw-r--r--src/mongo/client/query.h182
-rw-r--r--src/mongo/db/ops/SConscript3
-rw-r--r--src/mongo/executor/SConscript4
-rw-r--r--src/mongo/rpc/SConscript6
-rw-r--r--src/mongo/tools/SConscript8
-rw-r--r--src/mongo/util/SConscript3
10 files changed, 394 insertions, 313 deletions
diff --git a/src/mongo/client/SConscript b/src/mongo/client/SConscript
index 1506ad0b680..042e0f65fef 100644
--- a/src/mongo/client/SConscript
+++ b/src/mongo/client/SConscript
@@ -120,6 +120,18 @@ env.CppUnitTest(
)
env.Library(
+ target='client_query',
+ source=[
+ 'query.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/base',
+ 'read_preference',
+ ],
+)
+
+
+env.Library(
target='clientdriver',
source=[
'connection_string_connect.cpp',
@@ -138,6 +150,9 @@ env.Library(
'$BUILD_DIR/mongo/db/dbmessage',
'$BUILD_DIR/mongo/db/write_concern_options',
'$BUILD_DIR/mongo/executor/connection_pool_stats',
+ '$BUILD_DIR/mongo/executor/network_interface_factory',
+ '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
+ '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
'$BUILD_DIR/mongo/rpc/command_status',
'$BUILD_DIR/mongo/rpc/rpc',
'$BUILD_DIR/mongo/util/net/network',
@@ -210,9 +225,6 @@ env.CppUnitTest(
LIBDEPS=[
'$BUILD_DIR/mongo/db/write_concern_options',
'clientdriver',
- '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
- '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
- '$BUILD_DIR/mongo/executor/network_interface_factory'
]
)
@@ -221,9 +233,6 @@ env.CppUnitTest('dbclient_rs_test',
LIBDEPS=[
'clientdriver',
'$BUILD_DIR/mongo/dbtests/mocklib',
- '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
- '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
- '$BUILD_DIR/mongo/executor/network_interface_factory'
]
)
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index 7e7a7528b76..f42f1c3a2e3 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -108,130 +108,6 @@ SSLManagerInterface* sslManager() {
AtomicInt64 DBClientBase::ConnectionIdSequence;
-const BSONField<BSONObj> Query::ReadPrefField("$readPreference");
-const BSONField<string> Query::ReadPrefModeField("mode");
-const BSONField<BSONArray> Query::ReadPrefTagsField("tags");
-
-Query::Query(const string& json) : obj(fromjson(json)) {}
-
-Query::Query(const char* json) : obj(fromjson(json)) {}
-
-Query& Query::hint(const string& jsonKeyPatt) {
- return hint(fromjson(jsonKeyPatt));
-}
-
-Query& Query::where(const string& jscode, BSONObj scope) {
- /* use where() before sort() and hint() and explain(), else this will assert. */
- verify(!isComplex());
- BSONObjBuilder b;
- b.appendElements(obj);
- b.appendWhere(jscode, scope);
- obj = b.obj();
- return *this;
-}
-
-void Query::makeComplex() {
- if (isComplex())
- return;
- BSONObjBuilder b;
- b.append("query", obj);
- obj = b.obj();
-}
-
-Query& Query::sort(const BSONObj& s) {
- appendComplex("orderby", s);
- return *this;
-}
-
-Query& Query::hint(BSONObj keyPattern) {
- appendComplex("$hint", keyPattern);
- return *this;
-}
-
-Query& Query::explain() {
- appendComplex("$explain", true);
- return *this;
-}
-
-Query& Query::snapshot() {
- appendComplex("$snapshot", true);
- return *this;
-}
-
-Query& Query::minKey(const BSONObj& val) {
- appendComplex("$min", val);
- return *this;
-}
-
-Query& Query::maxKey(const BSONObj& val) {
- appendComplex("$max", val);
- return *this;
-}
-
-bool Query::isComplex(const BSONObj& obj, bool* hasDollar) {
- if (obj.hasElement("query")) {
- if (hasDollar)
- *hasDollar = false;
- return true;
- }
-
- if (obj.hasElement("$query")) {
- if (hasDollar)
- *hasDollar = true;
- return true;
- }
-
- return false;
-}
-
-Query& Query::readPref(ReadPreference pref, const BSONArray& tags) {
- appendComplex(ReadPrefField.name().c_str(), ReadPreferenceSetting(pref, TagSet(tags)).toBSON());
- return *this;
-}
-
-bool Query::isComplex(bool* hasDollar) const {
- return isComplex(obj, hasDollar);
-}
-
-bool Query::hasReadPreference(const BSONObj& queryObj) {
- const bool hasReadPrefOption = queryObj["$queryOptions"].isABSONObj() &&
- queryObj["$queryOptions"].Obj().hasField(ReadPrefField.name());
-
- bool canHaveReadPrefField = Query::isComplex(queryObj) ||
- // The find command has a '$readPreference' option.
- queryObj.firstElementFieldName() == StringData("find");
-
- return (canHaveReadPrefField && queryObj.hasField(ReadPrefField.name())) || hasReadPrefOption;
-}
-
-BSONObj Query::getFilter() const {
- bool hasDollar;
- if (!isComplex(&hasDollar))
- return obj;
-
- return obj.getObjectField(hasDollar ? "$query" : "query");
-}
-BSONObj Query::getSort() const {
- if (!isComplex())
- return BSONObj();
- BSONObj ret = obj.getObjectField("orderby");
- if (ret.isEmpty())
- ret = obj.getObjectField("$orderby");
- return ret;
-}
-BSONObj Query::getHint() const {
- if (!isComplex())
- return BSONObj();
- return obj.getObjectField("$hint");
-}
-bool Query::isExplain() const {
- return isComplex() && obj.getBoolField("$explain");
-}
-
-string Query::toString() const {
- return obj.toString();
-}
-
/* --- dbclientcommands --- */
bool DBClientWithCommands::isOk(const BSONObj& o) {
@@ -1433,29 +1309,6 @@ void DBClientWithCommands::ensureIndex(const string& ns,
}
/* -- DBClientCursor ---------------------------------------------- */
-void assembleQueryRequest(const string& ns,
- BSONObj query,
- int nToReturn,
- int nToSkip,
- const BSONObj* fieldsToReturn,
- int queryOptions,
- Message& toSend) {
- if (kDebugBuild) {
- massert(10337, (string) "object not valid assembleRequest query", query.isValid());
- }
-
- // see query.h for the protocol we are using here.
- BufBuilder b;
- int opts = queryOptions;
- b.appendNum(opts);
- b.appendStr(ns);
- b.appendNum(nToSkip);
- b.appendNum(nToReturn);
- query.appendSelfToBufBuilder(b);
- if (fieldsToReturn)
- fieldsToReturn->appendSelfToBufBuilder(b);
- toSend.setData(dbQuery, b.buf(), b.len());
-}
DBClientConnection::DBClientConnection(bool _autoReconnect,
double so_timeout,
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h
index dc6624aef5d..ed0e312673f 100644
--- a/src/mongo/client/dbclientinterface.h
+++ b/src/mongo/client/dbclientinterface.h
@@ -33,6 +33,7 @@
#include "mongo/base/string_data.h"
#include "mongo/client/connection_string.h"
#include "mongo/client/read_preference.h"
+#include "mongo/client/query.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/platform/atomic_word.h"
@@ -151,141 +152,6 @@ enum ReservedOptions {
class DBClientCursor;
class DBClientCursorBatchIterator;
-/** Represents a Mongo query expression. Typically one uses the QUERY(...) macro to construct a
- * Query object.
- Examples:
- QUERY( "age" << 33 << "school" << "UCLA" ).sort("name")
- QUERY( "age" << GT << 30 << LT << 50 )
-*/
-class Query {
-public:
- static const BSONField<BSONObj> ReadPrefField;
- static const BSONField<std::string> ReadPrefModeField;
- static const BSONField<BSONArray> ReadPrefTagsField;
-
- BSONObj obj;
- Query() : obj(BSONObj()) {}
- Query(const BSONObj& b) : obj(b) {}
- Query(const std::string& json);
- Query(const char* json);
-
- /** Add a sort (ORDER BY) criteria to the query expression.
- @param sortPattern the sort order template. For example to order by name ascending, time
- descending:
- { name : 1, ts : -1 }
- i.e.
- BSON( "name" << 1 << "ts" << -1 )
- or
- fromjson(" name : 1, ts : -1 ")
- */
- Query& sort(const BSONObj& sortPattern);
-
- /** Add a sort (ORDER BY) criteria to the query expression.
- This version of sort() assumes you want to sort on a single field.
- @param asc = 1 for ascending order
- asc = -1 for descending order
- */
- Query& sort(const std::string& field, int asc = 1) {
- sort(BSON(field << asc));
- return *this;
- }
-
- /** Provide a hint to the query.
- @param keyPattern Key pattern for the index to use.
- Example:
- hint("{ts:1}")
- */
- Query& hint(BSONObj keyPattern);
- Query& hint(const std::string& jsonKeyPatt);
-
- /** Provide min and/or max index limits for the query.
- min <= x < max
- */
- Query& minKey(const BSONObj& val);
- /**
- max is exclusive
- */
- Query& maxKey(const BSONObj& val);
-
- /** Return explain information about execution of this query instead of the actual query
- * results.
- * Normally it is easier to use the mongo shell to run db.find(...).explain().
- */
- Query& explain();
-
- /** Use snapshot mode for the query. Snapshot mode assures no duplicates are returned, or
- * objects missed, which were present at both the start and end of the query's execution (if an
- * object is new during the query, or deleted during the query, it may or may not be returned,
- * even with snapshot mode).
-
- Note that short query responses (less than 1MB) are always effectively snapshotted.
-
- Currently, snapshot mode may not be used with sorting or explicit hints.
- */
- Query& snapshot();
-
- /** Queries to the Mongo database support a $where parameter option which contains
- a javascript function that is evaluated to see whether objects being queried match
- its criteria. Use this helper to append such a function to a query object.
- Your query may also contain other traditional Mongo query terms.
-
- @param jscode The javascript function to evaluate against each potential object
- match. The function must return true for matched objects. Use the this
- variable to inspect the current object.
- @param scope SavedContext for the javascript object. List in a BSON object any
- variables you would like defined when the jscode executes. One can think
- of these as "bind variables".
-
- Examples:
- conn.findOne("test.coll", Query("{a:3}").where("this.b == 2 || this.c == 3"));
- Query badBalance = Query().where("this.debits - this.credits < 0");
- */
- Query& where(const std::string& jscode, BSONObj scope);
- Query& where(const std::string& jscode) {
- return where(jscode, BSONObj());
- }
-
- /**
- * Sets the read preference for this query.
- *
- * @param pref the read preference mode for this query.
- * @param tags the set of tags to use for this query.
- */
- Query& readPref(ReadPreference pref, const BSONArray& tags);
-
- /**
- * @return true if this query has an orderby, hint, or some other field
- */
- bool isComplex(bool* hasDollar = 0) const;
- static bool isComplex(const BSONObj& obj, bool* hasDollar = 0);
-
- BSONObj getFilter() const;
- BSONObj getSort() const;
- BSONObj getHint() const;
- bool isExplain() const;
-
- /**
- * @return true if the query object contains a read preference specification object.
- */
- static bool hasReadPreference(const BSONObj& queryObj);
-
- std::string toString() const;
- operator std::string() const {
- return toString();
- }
-
-private:
- void makeComplex();
- template <class T>
- void appendComplex(const char* fieldName, const T& val) {
- makeComplex();
- BSONObjBuilder b;
- b.appendElements(obj);
- b.append(fieldName, val);
- obj = b.obj();
- }
-};
-
/**
* Represents a full query description, including all options required for the query to be passed on
* to other hosts
@@ -1291,14 +1157,6 @@ inline std::ostream& operator<<(std::ostream& s, const Query& q) {
return s << q.toString();
}
-void assembleQueryRequest(const std::string& ns,
- BSONObj query,
- int nToReturn,
- int nToSkip,
- const BSONObj* fieldsToReturn,
- int queryOptions,
- Message& toSend);
-
} // namespace mongo
#include "mongo/client/dbclientcursor.h"
diff --git a/src/mongo/client/query.cpp b/src/mongo/client/query.cpp
new file mode 100644
index 00000000000..419f5b485e0
--- /dev/null
+++ b/src/mongo/client/query.cpp
@@ -0,0 +1,189 @@
+/* Copyright 2016 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/client/query.h"
+
+#include "mongo/base/status.h"
+#include "mongo/base/status_with.h"
+#include "mongo/bson/util/builder.h"
+
+namespace mongo {
+
+using std::string;
+
+const BSONField<BSONObj> Query::ReadPrefField("$readPreference");
+const BSONField<string> Query::ReadPrefModeField("mode");
+const BSONField<BSONArray> Query::ReadPrefTagsField("tags");
+
+
+Query::Query(const string& json) : obj(fromjson(json)) {}
+
+Query::Query(const char* json) : obj(fromjson(json)) {}
+
+Query& Query::hint(const string& jsonKeyPatt) {
+ return hint(fromjson(jsonKeyPatt));
+}
+
+Query& Query::where(const string& jscode, BSONObj scope) {
+ /* use where() before sort() and hint() and explain(), else this will assert. */
+ verify(!isComplex());
+ BSONObjBuilder b;
+ b.appendElements(obj);
+ b.appendWhere(jscode, scope);
+ obj = b.obj();
+ return *this;
+}
+
+void Query::makeComplex() {
+ if (isComplex())
+ return;
+ BSONObjBuilder b;
+ b.append("query", obj);
+ obj = b.obj();
+}
+
+Query& Query::sort(const BSONObj& s) {
+ appendComplex("orderby", s);
+ return *this;
+}
+
+Query& Query::hint(BSONObj keyPattern) {
+ appendComplex("$hint", keyPattern);
+ return *this;
+}
+
+Query& Query::explain() {
+ appendComplex("$explain", true);
+ return *this;
+}
+
+Query& Query::snapshot() {
+ appendComplex("$snapshot", true);
+ return *this;
+}
+
+Query& Query::minKey(const BSONObj& val) {
+ appendComplex("$min", val);
+ return *this;
+}
+
+Query& Query::maxKey(const BSONObj& val) {
+ appendComplex("$max", val);
+ return *this;
+}
+
+bool Query::isComplex(const BSONObj& obj, bool* hasDollar) {
+ if (obj.hasElement("query")) {
+ if (hasDollar)
+ *hasDollar = false;
+ return true;
+ }
+
+ if (obj.hasElement("$query")) {
+ if (hasDollar)
+ *hasDollar = true;
+ return true;
+ }
+
+ return false;
+}
+
+Query& Query::readPref(ReadPreference pref, const BSONArray& tags) {
+ appendComplex(ReadPrefField.name().c_str(), ReadPreferenceSetting(pref, TagSet(tags)).toBSON());
+ return *this;
+}
+
+bool Query::isComplex(bool* hasDollar) const {
+ return isComplex(obj, hasDollar);
+}
+
+bool Query::hasReadPreference(const BSONObj& queryObj) {
+ const bool hasReadPrefOption = queryObj["$queryOptions"].isABSONObj() &&
+ queryObj["$queryOptions"].Obj().hasField(ReadPrefField.name());
+
+ bool canHaveReadPrefField = Query::isComplex(queryObj) ||
+ // The find command has a '$readPreference' option.
+ queryObj.firstElementFieldName() == StringData("find");
+
+ return (canHaveReadPrefField && queryObj.hasField(ReadPrefField.name())) || hasReadPrefOption;
+}
+
+BSONObj Query::getFilter() const {
+ bool hasDollar;
+ if (!isComplex(&hasDollar))
+ return obj;
+
+ return obj.getObjectField(hasDollar ? "$query" : "query");
+}
+BSONObj Query::getSort() const {
+ if (!isComplex())
+ return BSONObj();
+ BSONObj ret = obj.getObjectField("orderby");
+ if (ret.isEmpty())
+ ret = obj.getObjectField("$orderby");
+ return ret;
+}
+BSONObj Query::getHint() const {
+ if (!isComplex())
+ return BSONObj();
+ return obj.getObjectField("$hint");
+}
+bool Query::isExplain() const {
+ return isComplex() && obj.getBoolField("$explain");
+}
+
+string Query::toString() const {
+ return obj.toString();
+}
+
+void assembleQueryRequest(const string& ns,
+ BSONObj query,
+ int nToReturn,
+ int nToSkip,
+ const BSONObj* fieldsToReturn,
+ int queryOptions,
+ Message& toSend) {
+ if (kDebugBuild) {
+ massert(10337, (string) "object not valid assembleRequest query", query.isValid());
+ }
+
+ // see query.h for the protocol we are using here.
+ BufBuilder b;
+ int opts = queryOptions;
+ b.appendNum(opts);
+ b.appendStr(ns);
+ b.appendNum(nToSkip);
+ b.appendNum(nToReturn);
+ query.appendSelfToBufBuilder(b);
+ if (fieldsToReturn)
+ fieldsToReturn->appendSelfToBufBuilder(b);
+ toSend.setData(dbQuery, b.buf(), b.len());
+}
+
+} // namespace mongo
diff --git a/src/mongo/client/query.h b/src/mongo/client/query.h
new file mode 100644
index 00000000000..4a4a97bd9b8
--- /dev/null
+++ b/src/mongo/client/query.h
@@ -0,0 +1,182 @@
+/**
+ * Copyright (C) 2016 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#pragma once
+
+#include "mongo/bson/json.h"
+#include "mongo/client/read_preference.h"
+#include "mongo/util/net/message.h"
+
+
+namespace mongo {
+
+/** Represents a Mongo query expression. Typically one uses the QUERY(...) macro to construct a
+ * Query object.
+ Examples:
+ QUERY( "age" << 33 << "school" << "UCLA" ).sort("name")
+ QUERY( "age" << GT << 30 << LT << 50 )
+*/
+
+class Query {
+public:
+ static const BSONField<BSONObj> ReadPrefField;
+ static const BSONField<std::string> ReadPrefModeField;
+ static const BSONField<BSONArray> ReadPrefTagsField;
+
+ BSONObj obj;
+ Query() : obj(BSONObj()) {}
+ Query(const BSONObj& b) : obj(b) {}
+ Query(const std::string& json);
+ Query(const char* json);
+
+ /** Add a sort (ORDER BY) criteria to the query expression.
+ @param sortPattern the sort order template. For example to order by name ascending, time
+ descending:
+ { name : 1, ts : -1 }
+ i.e.
+ BSON( "name" << 1 << "ts" << -1 )
+ or
+ fromjson(" name : 1, ts : -1 ")
+ */
+ Query& sort(const BSONObj& sortPattern);
+
+ /** Add a sort (ORDER BY) criteria to the query expression.
+ This version of sort() assumes you want to sort on a single field.
+ @param asc = 1 for ascending order
+ asc = -1 for descending order
+ */
+ Query& sort(const std::string& field, int asc = 1) {
+ sort(BSON(field << asc));
+ return *this;
+ }
+
+ /** Provide a hint to the query.
+ @param keyPattern Key pattern for the index to use.
+ Example:
+ hint("{ts:1}")
+ */
+ Query& hint(BSONObj keyPattern);
+ Query& hint(const std::string& jsonKeyPatt);
+
+ /** Provide min and/or max index limits for the query.
+ min <= x < max
+ */
+ Query& minKey(const BSONObj& val);
+ /**
+ max is exclusive
+ */
+ Query& maxKey(const BSONObj& val);
+
+ /** Return explain information about execution of this query instead of the actual query
+ * results.
+ * Normally it is easier to use the mongo shell to run db.find(...).explain().
+ */
+ Query& explain();
+
+ /** Use snapshot mode for the query. Snapshot mode assures no duplicates are returned, or
+ * objects missed, which were present at both the start and end of the query's execution (if an
+ * object is new during the query, or deleted during the query, it may or may not be returned,
+ * even with snapshot mode).
+
+ Note that short query responses (less than 1MB) are always effectively snapshotted.
+
+ Currently, snapshot mode may not be used with sorting or explicit hints.
+ */
+ Query& snapshot();
+
+ /** Queries to the Mongo database support a $where parameter option which contains
+ a javascript function that is evaluated to see whether objects being queried match
+ its criteria. Use this helper to append such a function to a query object.
+ Your query may also contain other traditional Mongo query terms.
+
+ @param jscode The javascript function to evaluate against each potential object
+ match. The function must return true for matched objects. Use the this
+ variable to inspect the current object.
+ @param scope SavedContext for the javascript object. List in a BSON object any
+ variables you would like defined when the jscode executes. One can think
+ of these as "bind variables".
+
+ Examples:
+ conn.findOne("test.coll", Query("{a:3}").where("this.b == 2 || this.c == 3"));
+ Query badBalance = Query().where("this.debits - this.credits < 0");
+ */
+ Query& where(const std::string& jscode, BSONObj scope);
+ Query& where(const std::string& jscode) {
+ return where(jscode, BSONObj());
+ }
+
+ /**
+ * Sets the read preference for this query.
+ *
+ * @param pref the read preference mode for this query.
+ * @param tags the set of tags to use for this query.
+ */
+ Query& readPref(ReadPreference pref, const BSONArray& tags);
+
+ /**
+ * @return true if this query has an orderby, hint, or some other field
+ */
+ bool isComplex(bool* hasDollar = 0) const;
+ static bool isComplex(const BSONObj& obj, bool* hasDollar = 0);
+
+ BSONObj getFilter() const;
+ BSONObj getSort() const;
+ BSONObj getHint() const;
+ bool isExplain() const;
+
+ /**
+ * @return true if the query object contains a read preference specification object.
+ */
+ static bool hasReadPreference(const BSONObj& queryObj);
+
+ std::string toString() const;
+ operator std::string() const {
+ return toString();
+ }
+
+private:
+ void makeComplex();
+ template <class T>
+ void appendComplex(const char* fieldName, const T& val) {
+ makeComplex();
+ BSONObjBuilder b;
+ b.appendElements(obj);
+ b.append(fieldName, val);
+ obj = b.obj();
+ }
+};
+
+void assembleQueryRequest(const std::string& ns,
+ BSONObj query,
+ int nToReturn,
+ int nToSkip,
+ const BSONObj* fieldsToReturn,
+ int queryOptions,
+ Message& toSend);
+
+} // namespace mongo
diff --git a/src/mongo/db/ops/SConscript b/src/mongo/db/ops/SConscript
index e79871b556f..ab345cb238c 100644
--- a/src/mongo/db/ops/SConscript
+++ b/src/mongo/db/ops/SConscript
@@ -255,8 +255,5 @@ env.CppUnitTest(
LIBDEPS=[
'write_ops_parsers',
'$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
- '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
- '$BUILD_DIR/mongo/executor/network_interface_factory'
],
)
diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript
index 14230ff0f70..b138a11f1e1 100644
--- a/src/mongo/executor/SConscript
+++ b/src/mongo/executor/SConscript
@@ -316,11 +316,13 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/client/clientdriver',
+ '$BUILD_DIR/mongo/client/client_query',
'$BUILD_DIR/mongo/db/query/command_request_response',
'$BUILD_DIR/mongo/db/query/command_request_response',
'$BUILD_DIR/mongo/db/query/lite_parsed_query',
'$BUILD_DIR/mongo/rpc/protocol',
+ '$BUILD_DIR/mongo/rpc/metadata',
+ '$BUILD_DIR/mongo/util/net/network',
],
)
diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript
index 7fab290eb69..7822e216189 100644
--- a/src/mongo/rpc/SConscript
+++ b/src/mongo/rpc/SConscript
@@ -174,12 +174,8 @@ env.CppUnitTest(
'reply_builder_test.cpp',
],
LIBDEPS=[
- 'rpc',
'$BUILD_DIR/mongo/client/clientdriver',
- '$BUILD_DIR/mongo/db/write_concern_options',
- '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
- '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
- '$BUILD_DIR/mongo/executor/network_interface_factory'
+ 'rpc',
],
)
diff --git a/src/mongo/tools/SConscript b/src/mongo/tools/SConscript
index c0f9947afb5..15e37297202 100644
--- a/src/mongo/tools/SConscript
+++ b/src/mongo/tools/SConscript
@@ -11,15 +11,7 @@ mongobridge = env.Program(
"mongobridge_options_init.cpp"
],
LIBDEPS=[
- "$BUILD_DIR/mongo/base",
"$BUILD_DIR/mongo/client/clientdriver",
- "$BUILD_DIR/mongo/db/commands/test_commands_enabled",
- "$BUILD_DIR/mongo/db/service_context",
- "$BUILD_DIR/mongo/db/write_concern_options",
- '$BUILD_DIR/mongo/executor/thread_pool_task_executor',
- '$BUILD_DIR/mongo/executor/network_interface_thread_pool',
- '$BUILD_DIR/mongo/executor/network_interface_factory',
- "$BUILD_DIR/mongo/util/net/network",
"$BUILD_DIR/mongo/util/ntservice_mock",
"$BUILD_DIR/mongo/util/signal_handlers",
"$BUILD_DIR/mongo/util/options_parser/options_parser_init",
diff --git a/src/mongo/util/SConscript b/src/mongo/util/SConscript
index 8583220b9e7..6f7ce51979f 100644
--- a/src/mongo/util/SConscript
+++ b/src/mongo/util/SConscript
@@ -134,6 +134,9 @@ env.Library(
'clock_source_mock.cpp',
'tick_source_mock.cpp',
],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/base',
+ ],
)
env.CppUnitTest(