summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/dbclient.cpp9
-rw-r--r--client/dbclient.h4
-rw-r--r--client/examples/authTest.cpp2
-rw-r--r--client/examples/clientTest.cpp4
-rw-r--r--client/examples/second.cpp4
-rw-r--r--client/examples/tutorial.cpp14
-rw-r--r--client/examples/whereExample.cpp4
-rw-r--r--client/gridfs.cpp2
-rw-r--r--db/cloner.cpp10
-rw-r--r--db/cursor.h6
-rw-r--r--db/dbhelpers.cpp6
-rw-r--r--db/dbwebserver.cpp2
-rw-r--r--db/instance.cpp2
-rw-r--r--db/jsobj.cpp35
-rw-r--r--db/jsobj.h38
-rw-r--r--db/json.cpp2
-rw-r--r--db/matcher.cpp2
-rw-r--r--db/namespace.cpp2
-rw-r--r--db/pdfile.cpp10
-rw-r--r--db/query.cpp6
-rw-r--r--db/queryoptimizer.cpp2
-rw-r--r--db/queryutil.h4
-rw-r--r--db/repl.cpp10
-rw-r--r--db/repl.h4
-rw-r--r--dbtests/jsobjtests.cpp4
-rw-r--r--dbtests/jsontests.cpp2
-rw-r--r--dbtests/pairingtests.cpp2
-rw-r--r--dbtests/perf/perftest.cpp10
-rw-r--r--dbtests/queryoptimizertests.cpp82
-rw-r--r--dbtests/querytests.cpp28
-rw-r--r--dbtests/repltests.cpp4
-rw-r--r--mongo.xcodeproj/project.pbxproj18
-rw-r--r--s/commands.cpp4
-rw-r--r--s/cursors.cpp6
-rw-r--r--s/cursors.h4
-rw-r--r--s/shardkey.h2
-rw-r--r--s/strategy_shard.cpp2
-rw-r--r--tools/dump.cpp4
38 files changed, 171 insertions, 185 deletions
diff --git a/client/dbclient.cpp b/client/dbclient.cpp
index 57425730f2e..2cfba890fa7 100644
--- a/client/dbclient.cpp
+++ b/client/dbclient.cpp
@@ -82,12 +82,12 @@ namespace mongo {
}
BSONObj Query::getSort() const {
if ( ! isComplex() )
- return emptyObj;
+ return BSONObj();
return obj.getObjectField( "orderby" );
}
BSONObj Query::getHint() const {
if ( ! isComplex() )
- return emptyObj;
+ return BSONObj();
return obj.getObjectField( "$hint" );
}
bool Query::isExplain() const {
@@ -730,7 +730,6 @@ namespace mongo {
/* ------------------------------------------------------ */
// "./db testclient" to invoke
- extern BSONObj emptyObj;
void testClient3() {
out() << "testClient()" << endl;
// DBClientConnection c(true);
@@ -747,7 +746,7 @@ namespace mongo {
again:
out() << "query foo.bar..." << endl;
auto_ptr<DBClientCursor> cursor =
- c.query("foo.bar", emptyObj, 0, 0, 0, Option_CursorTailable);
+ c.query("foo.bar", BSONObj(), 0, 0, 0, Option_CursorTailable);
DBClientCursor *cc = cursor.get();
if ( cc == 0 ) {
out() << "query() returned 0, sleeping 10 secs" << endl;
@@ -896,7 +895,7 @@ again:
while( 1 ) {
sleepsecs(3);
try {
- log() << "findone returns " << p.findOne("dwight.foo", emptyObj).toString() << endl;
+ log() << "findone returns " << p.findOne("dwight.foo", BSONObj()).toString() << endl;
sleepsecs(3);
BSONObj info;
bool im;
diff --git a/client/dbclient.h b/client/dbclient.h
index f01605dcc5c..ce65f44c495 100644
--- a/client/dbclient.h
+++ b/client/dbclient.h
@@ -56,7 +56,7 @@ namespace mongo {
class Query {
public:
BSONObj obj;
- Query() : obj(emptyObj) { }
+ Query() : obj(BSONObj()) { }
Query(const BSONObj& b) : obj(b) { }
Query(const string &json) :
obj(fromjson(json)) { }
@@ -293,7 +293,7 @@ namespace mongo {
/** count number of objects in collection ns that match the query criteria specified
throws UserAssertion if database returns an error
*/
- unsigned long long count(const char *ns, BSONObj query = emptyObj);
+ unsigned long long count(const char *ns, BSONObj query = BSONObj());
string createPasswordDigest( const char * username , const char * clearTextPassword );
diff --git a/client/examples/authTest.cpp b/client/examples/authTest.cpp
index 78fc57286b6..b027e957d9f 100644
--- a/client/examples/authTest.cpp
+++ b/client/examples/authTest.cpp
@@ -16,7 +16,7 @@ int main() {
}
{ // clean up old data from any previous tests
- conn.remove( "test.system.users" , emptyObj );
+ conn.remove( "test.system.users" , BSONObj() );
}
conn.insert( "test.system.users" , BSON( "user" << "eliot" << "pwd" << conn.createPasswordDigest( "eliot" , "bar" ) ) );
diff --git a/client/examples/clientTest.cpp b/client/examples/clientTest.cpp
index ba2fe90586e..7eb3c7e6f93 100644
--- a/client/examples/clientTest.cpp
+++ b/client/examples/clientTest.cpp
@@ -138,7 +138,7 @@ int main() {
conn.insert( tsns , b.obj() );
}
- mongo::BSONObj out = conn.findOne( tsns , mongo::emptyObj );
+ mongo::BSONObj out = conn.findOne( tsns , mongo::BSONObj() );
unsigned int inc = out["ts"].timestampInc();
{
@@ -152,7 +152,7 @@ int main() {
conn.update( tsns , b1.obj() , b2.obj() );
}
- assert( conn.findOne( tsns , mongo::emptyObj )["ts"].timestampInc() == ( inc + 1 ) );
+ assert( conn.findOne( tsns , mongo::BSONObj() )["ts"].timestampInc() == ( inc + 1 ) );
}
diff --git a/client/examples/second.cpp b/client/examples/second.cpp
index 2afd5736f96..86aba0bcbe7 100644
--- a/client/examples/second.cpp
+++ b/client/examples/second.cpp
@@ -18,12 +18,12 @@ int main() {
const char * ns = "test.second";
- conn.remove( ns , emptyObj );
+ conn.remove( ns , BSONObj() );
conn.insert( ns , BSON( "name" << "eliot" << "num" << 17 ) );
conn.insert( ns , BSON( "name" << "sara" << "num" << 24 ) );
- auto_ptr<DBClientCursor> cursor = conn.query( ns , emptyObj );
+ auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObj() );
cout << "using cursor" << endl;
while ( cursor->more() ) {
BSONObj obj = cursor->next();
diff --git a/client/examples/tutorial.cpp b/client/examples/tutorial.cpp
index b585af64fed..7720e6fcaa3 100644
--- a/client/examples/tutorial.cpp
+++ b/client/examples/tutorial.cpp
@@ -5,12 +5,12 @@
using namespace mongo;
-void printIfAge(DBClientConnection& c, int age) {
- auto_ptr<DBClientCursor> cursor = c.query("tutorial.persons", QUERY( "age" << age ).sort("name") );
- while( cursor->more() ) {
- BSONObj p = cursor->next();
- cout << p.getStringField("name") << endl;
- }
+void printIfAge(DBClientConnection& c, int age) {
+ auto_ptr<DBClientCursor> cursor = c.query("tutorial.persons", QUERY( "age" << age ).sort("name") );
+ while( cursor->more() ) {
+ BSONObj p = cursor->next();
+ cout << p.getStringField("name") << endl;
+ }
}
void run() {
@@ -30,7 +30,7 @@ void run() {
cout << "count:" << c.count("tutorial.persons") << endl;
- auto_ptr<DBClientCursor> cursor = c.query("tutorial.persons", emptyObj);
+ auto_ptr<DBClientCursor> cursor = c.query("tutorial.persons", BSONObj());
while( cursor->more() ) {
cout << cursor->next().toString() << endl;
}
diff --git a/client/examples/whereExample.cpp b/client/examples/whereExample.cpp
index a4d04bda1e3..2f83af6ea1f 100644
--- a/client/examples/whereExample.cpp
+++ b/client/examples/whereExample.cpp
@@ -18,12 +18,12 @@ int main() {
const char * ns = "test.where";
- conn.remove( ns , emptyObj );
+ conn.remove( ns , BSONObj() );
conn.insert( ns , BSON( "name" << "eliot" << "num" << 17 ) );
conn.insert( ns , BSON( "name" << "sara" << "num" << 24 ) );
- auto_ptr<DBClientCursor> cursor = conn.query( ns , emptyObj );
+ auto_ptr<DBClientCursor> cursor = conn.query( ns , BSONObj() );
while ( cursor->more() ) {
BSONObj obj = cursor->next();
diff --git a/client/gridfs.cpp b/client/gridfs.cpp
index 154cc034bd2..3c84e6cbcc3 100644
--- a/client/gridfs.cpp
+++ b/client/gridfs.cpp
@@ -107,7 +107,7 @@ namespace mongo {
}
auto_ptr<DBClientCursor> GridFS::list(){
- return _client.query( _filesNS.c_str() , emptyObj );
+ return _client.query( _filesNS.c_str() , BSONObj() );
}
auto_ptr<DBClientCursor> GridFS::list( BSONObj o ){
diff --git a/db/cloner.cpp b/db/cloner.cpp
index 279f56f3b01..e46112d2cfe 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -37,7 +37,7 @@ namespace mongo {
class Cloner: boost::noncopyable {
auto_ptr< DBClientWithCommands > conn;
void copy(const char *from_ns, const char *to_ns, bool isindex, bool logForRepl,
- bool masterSameProcess, bool slaveOk, BSONObj query = emptyObj);
+ bool masterSameProcess, bool slaveOk, BSONObj query = BSONObj());
void replayOpLog( DBClientCursor *c, const BSONObj &query );
public:
Cloner() { }
@@ -160,7 +160,7 @@ namespace mongo {
} else {
conn.reset( new DBDirectClient() );
}
- c = conn->query( ns.c_str(), emptyObj, 0, 0, 0, slaveOk ? Option_SlaveOk : 0 );
+ c = conn->query( ns.c_str(), BSONObj(), 0, 0, 0, slaveOk ? Option_SlaveOk : 0 );
}
if ( c.get() == 0 ) {
errmsg = "query failed " + ns;
@@ -378,7 +378,7 @@ namespace mongo {
}
BSONObj query = cmdObj.getObjectField("query");
if ( query.isEmpty() )
- query = emptyObj;
+ query = BSONObj();
BSONElement copyIndexesSpec = cmdObj.getField("copyindexes");
bool copyIndexes = copyIndexesSpec.isBoolean() ? copyIndexesSpec.boolean() : true;
// Will not be used if doesn't exist.
@@ -422,7 +422,7 @@ namespace mongo {
}
BSONObj query = cmdObj.getObjectField("query");
if ( query.isEmpty() )
- query = emptyObj;
+ query = BSONObj();
BSONElement copyIndexesSpec = cmdObj.getField("copyindexes");
bool copyIndexes = copyIndexesSpec.isBoolean() ? copyIndexesSpec.boolean() : true;
// Will not be used if doesn't exist.
@@ -479,7 +479,7 @@ namespace mongo {
}
BSONObj query = fromToken.getObjectField("query");
if ( query.isEmpty() ) {
- query = emptyObj;
+ query = BSONObj();
}
long long cursorId = 0;
BSONElement cursorIdToken = fromToken.getField( "cursorId" );
diff --git a/db/cursor.h b/db/cursor.h
index c87639d16ab..78cb389f509 100644
--- a/db/cursor.h
+++ b/db/cursor.h
@@ -52,7 +52,7 @@ namespace mongo {
virtual BSONObj current() = 0;
virtual DiskLoc currLoc() = 0;
virtual bool advance() = 0; /*true=ok*/
- virtual BSONObj currKey() const { return emptyObj; }
+ virtual BSONObj currKey() const { return BSONObj(); }
// DiskLoc the cursor requires for continued operation. Before this
// DiskLoc is deleted, the cursor must be incremented or destroyed.
virtual DiskLoc refLoc() = 0;
@@ -100,8 +100,8 @@ namespace mongo {
return false;
}
- virtual BSONObj prettyStartKey() const { return emptyObj; }
- virtual BSONObj prettyEndKey() const { return emptyObj; }
+ virtual BSONObj prettyStartKey() const { return BSONObj(); }
+ virtual BSONObj prettyEndKey() const { return BSONObj(); }
};
diff --git a/db/dbhelpers.cpp b/db/dbhelpers.cpp
index fa60386d8eb..b2a8a951b6b 100644
--- a/db/dbhelpers.cpp
+++ b/db/dbhelpers.cpp
@@ -88,7 +88,7 @@ namespace mongo {
set your db context first
*/
bool Helpers::findOne(const char *ns, BSONObj query, BSONObj& result, bool requireIndex) {
- QueryPlanSet s( ns, query, emptyObj );
+ QueryPlanSet s( ns, query, BSONObj() );
FindOne original( requireIndex );
shared_ptr< FindOne > res = s.runOp( original );
if ( res->one().isEmpty() )
@@ -132,12 +132,12 @@ namespace mongo {
void Helpers::putSingleton(const char *ns, BSONObj obj) {
DBContext context(ns);
stringstream ss;
- updateObjects(ns, obj, /*pattern=*/emptyObj, /*upsert=*/true, ss);
+ updateObjects(ns, obj, /*pattern=*/BSONObj(), /*upsert=*/true, ss);
}
void Helpers::emptyCollection(const char *ns) {
DBContext context(ns);
- deleteObjects(ns, emptyObj, false);
+ deleteObjects(ns, BSONObj(), false);
}
} // namespace mongo
diff --git a/db/dbwebserver.cpp b/db/dbwebserver.cpp
index a2424946408..93d20153dc5 100644
--- a/db/dbwebserver.cpp
+++ b/db/dbwebserver.cpp
@@ -167,7 +167,7 @@ namespace mongo {
bool allowed( const char * rq , vector<string>& headers ){
- if ( db.findOne( "admin.system.users" , emptyObj ).isEmpty() )
+ if ( db.findOne( "admin.system.users" , BSONObj() ).isEmpty() )
return true;
string auth = getHeader( rq , "Authorization" );
diff --git a/db/instance.cpp b/db/instance.cpp
index 9aa326e07bc..d3dee74c9b0 100644
--- a/db/instance.cpp
+++ b/db/instance.cpp
@@ -319,7 +319,7 @@ namespace mongo {
bool justOne = flags & 1;
assert( d.moreJSObjs() );
BSONObj pattern = d.nextJsObj();
- BSONObj deletedId = emptyObj;
+ BSONObj deletedId = BSONObj();
deleteObjects(ns, pattern, justOne, &deletedId);
if ( justOne ) {
if ( deletedId.isEmpty() ) {
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index 9f14bf8955a..690a9bc4880 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -562,6 +562,8 @@ namespace mongo {
/* BSONObj ------------------------------------------------------------*/
+ BSONObj::EmptyObject BSONObj::emptyObject;
+
string BSONObj::toString() const {
if ( isEmpty() ) return "{}";
@@ -694,15 +696,13 @@ namespace mongo {
BSONElement BSONObj::getField(const char *name) const {
- if ( objdata() ) {
- BSONObjIterator i(*this);
- while ( i.more() ) {
- BSONElement e = i.next();
- if ( e.eoo() )
- break;
- if ( strcmp(e.fieldName(), name) == 0 )
- return e;
- }
+ BSONObjIterator i(*this);
+ while ( i.more() ) {
+ BSONElement e = i.next();
+ if ( e.eoo() )
+ break;
+ if ( strcmp(e.fieldName(), name) == 0 )
+ return e;
}
return nullElement;
}
@@ -909,7 +909,7 @@ namespace mongo {
returns n added not counting _id unless requested.
*/
int BSONObj::addFields(BSONObj& from, set<string>& fields) {
- assert( objdata() == 0 ); /* partial implementation for now... */
+ assert( isEmpty() && !isOwned() ); /* partial implementation for now... */
BSONObjBuilder b;
@@ -973,7 +973,7 @@ namespace mongo {
BSONObjBuilder b;
BSONObjIterator i( *this );
BSONObjIterator j( names );
- BSONElement f = j.more() ? j.next() : emptyObj.firstElement();
+ BSONElement f = j.more() ? j.next() : BSONObj().firstElement();
while( i.more() ) {
BSONElement e = i.next();
if ( e.eoo() )
@@ -1059,19 +1059,6 @@ namespace mongo {
totalSize = -1;
}
-#pragma pack(1)
- struct EmptyObject {
- EmptyObject() {
- len = 5;
- jstype = EOO;
- }
- int len;
- char jstype;
- } emptyObject;
-#pragma pack()
-
- BSONObj emptyObj((char *) &emptyObject);
-
struct BsonUnitTest : public UnitTest {
void testRegex() {
BSONObjBuilder b;
diff --git a/db/jsobj.h b/db/jsobj.h
index f44974fd574..63b97cd801c 100644
--- a/db/jsobj.h
+++ b/db/jsobj.h
@@ -482,6 +482,16 @@ namespace mongo {
_objdata = data;
massert( "Invalid BSONObj spec size", isValid() );
}
+#pragma pack(1)
+ static struct EmptyObject {
+ EmptyObject() {
+ len = 5;
+ jstype = EOO;
+ }
+ int len;
+ char jstype;
+ } emptyObject;
+#pragma pack()
public:
/** Construct a BSONObj from data in the proper format.
@param ifree true if the BSONObj should free() the msgdata when
@@ -492,8 +502,7 @@ namespace mongo {
}
BSONObj(const Record *r);
/** Construct an empty BSONObj -- that is, {}. */
- // TODO: Unify this with 'emptyObj'
- BSONObj() : _objdata(0) { }
+ BSONObj() : _objdata( reinterpret_cast< const char * >( &emptyObject ) ) { }
// defensive
~BSONObj() { _objdata = 0; }
@@ -604,8 +613,6 @@ namespace mongo {
}
/** @return total size of the BSON object in bytes */
int objsize() const {
- if ( !objdata() )
- return 0;
return *(reinterpret_cast<const int*>(objdata()));
}
@@ -616,12 +623,9 @@ namespace mongo {
return objsize() <= 5;
}
- void validateEmpty();
-
void dump() {
out() << hex;
const char *p = objdata();
- if ( !p ) return;
for ( int i = 0; i < objsize(); i++ ) {
out() << i << '\t' << (unsigned) *p;
if ( *p >= 'A' && *p <= 'z' )
@@ -778,13 +782,6 @@ namespace mongo {
BSONObjBuilder& operator<<( T value );
Labeler operator<<( const Labeler::Label &l );
-/*
- BSONObjBuilder& operator<<( const char * value );
- BSONObjBuilder& operator<<( const string& v ) { return (*this << v.c_str()); }
- BSONObjBuilder& operator<<( const int value );
- BSONObjBuilder& operator<<( const double value );
- BSONObjBuilder& operator<<( const unsigned long value ){ return (*this << (double)value); }
-*/
void endField( const char *nextFieldName = 0 );
bool subobjStarted() const { return _fieldName != 0; }
@@ -1210,9 +1207,6 @@ namespace mongo {
}
inline BSONObj BSONObj::copy() const {
- if ( !objdata() )
- return *this;
-
char *p = (char*) malloc(objsize());
memcpy(p, objdata(), objsize());
return BSONObj(p, true);
@@ -1260,17 +1254,7 @@ namespace mongo {
return *this;
}
- extern BSONObj emptyObj;
-
- inline void BSONObj::validateEmpty() {
- if ( objdata() == 0 )
- *this = emptyObj;
- }
-
inline bool BSONObj::isValid(){
- if ( !objdata() )
- return true;
-
return objsize() > 0 && objsize() <= 1024 * 1024 * 16 ;
}
diff --git a/db/json.cpp b/db/json.cpp
index 595ab76599d..b32d3c69844 100644
--- a/db/json.cpp
+++ b/db/json.cpp
@@ -524,7 +524,7 @@ public:
BSONObj fromjson( const char *str ) {
if ( ! strlen(str) )
- return emptyObj;
+ return BSONObj();
ObjectBuilder b;
JsonGrammar parser( b );
parse_info<> result = parse( str, parser, space_p );
diff --git a/db/matcher.cpp b/db/matcher.cpp
index 98e2691c906..73cda343333 100644
--- a/db/matcher.cpp
+++ b/db/matcher.cpp
@@ -523,7 +523,7 @@ namespace mongo {
assert( n.matches(j1) );
assert( !n.matches(j2) );
- BSONObj j0 = emptyObj;
+ BSONObj j0 = BSONObj();
// BSONObj j0((const char *) &js0);
JSMatcher p(j0);
assert( p.matches(j1) );
diff --git a/db/namespace.cpp b/db/namespace.cpp
index b40d0076de6..e97139f1428 100644
--- a/db/namespace.cpp
+++ b/db/namespace.cpp
@@ -576,7 +576,7 @@ namespace mongo {
/* add a new namespace to the system catalog (<dbname>.system.namespaces).
options: { capped : ..., size : ... }
*/
- void addNewNamespaceToCatalog(const char *ns, BSONObj *options = 0) {
+ void addNewNamespaceToCatalog(const char *ns, const BSONObj *options = 0) {
log(1) << "New namespace: " << ns << '\n';
if ( strstr(ns, "system.namespaces") ) {
// system.namespaces holds all the others, so it is not explicitly listed in the catalog.
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index c0470a4a8c9..87198a72897 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -54,7 +54,7 @@ namespace mongo {
int callDepth = 0;
extern int otherTraceLevel;
- void addNewNamespaceToCatalog(const char *ns, BSONObj *options = 0);
+ void addNewNamespaceToCatalog(const char *ns, const BSONObj *options = 0);
string getDbContext() {
stringstream ss;
@@ -98,7 +98,7 @@ namespace mongo {
return z;
}
- bool _userCreateNS(const char *ns, BSONObj& j, string& err) {
+ bool _userCreateNS(const char *ns, const BSONObj& j, string& err) {
if ( nsdetails(ns) ) {
err = "collection already exists";
return false;
@@ -160,7 +160,6 @@ namespace mongo {
// { ..., capped: true, size: ..., max: ... }
// returns true if successful
bool userCreateNS(const char *ns, BSONObj j, string& err, bool logForReplication) {
- j.validateEmpty();
bool ok = _userCreateNS(ns, j, err);
if ( logForReplication && ok )
logOp("c", ns, j);
@@ -543,7 +542,7 @@ assert( !eloc.isNull() );
NamespaceDetails *freeExtents = nsdetails(s.c_str());
if( freeExtents == 0 ) {
string err;
- _userCreateNS(s.c_str(), emptyObj, err);
+ _userCreateNS(s.c_str(), BSONObj(), err);
freeExtents = nsdetails(s.c_str());
massert("can't create .$freelist", freeExtents);
}
@@ -998,7 +997,6 @@ assert( !eloc.isNull() );
}
}
- extern BSONObj emptyObj;
extern BSONObj id_obj;
void ensureHaveIdIndex(const char *ns) {
@@ -1114,7 +1112,7 @@ assert( !eloc.isNull() );
if ( tableToIndex == 0 ) {
// try to create it
string err;
- if ( !userCreateNS(tabletoidxns.c_str(), emptyObj, err, false) ) {
+ if ( !userCreateNS(tabletoidxns.c_str(), BSONObj(), err, false) ) {
problem() << "ERROR: failed to create collection while adding its index. " << tabletoidxns << endl;
return DiskLoc();
}
diff --git a/db/query.cpp b/db/query.cpp
index b4e8083dc25..d33e20c70e1 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -120,7 +120,7 @@ namespace mongo {
}
int nDeleted = 0;
- QueryPlanSet s( ns, pattern, emptyObj );
+ QueryPlanSet s( ns, pattern, BSONObj() );
int best = 0;
DeleteOp original( justOne, best );
shared_ptr< DeleteOp > bestOp = s.runOp( original );
@@ -389,7 +389,7 @@ namespace mongo {
}
}
- QueryPlanSet qps( ns, pattern, emptyObj );
+ QueryPlanSet qps( ns, pattern, BSONObj() );
UpdateOp original;
shared_ptr< UpdateOp > u = qps.runOp( original );
massert( u->exceptionMessage(), u->complete() );
@@ -736,7 +736,7 @@ namespace mongo {
if ( query.isEmpty() && fields.isEmpty() ) {
return d->nrecords;
}
- QueryPlanSet qps( ns, query, emptyObj );
+ QueryPlanSet qps( ns, query, BSONObj() );
CountOp original( cmd );
shared_ptr< CountOp > res = qps.runOp( original );
if ( !res->complete() ) {
diff --git a/db/queryoptimizer.cpp b/db/queryoptimizer.cpp
index 0a7df763b9f..0ecf2bbdab0 100644
--- a/db/queryoptimizer.cpp
+++ b/db/queryoptimizer.cpp
@@ -163,7 +163,7 @@ namespace mongo {
fbs_( ns, query ),
mayRecordPlan_( true ),
usingPrerecordedPlan_( false ),
- hint_( emptyObj ),
+ hint_( BSONObj() ),
order_( order.getOwned() ),
oldNScanned_( 0 ),
honorRecordedPlan_( honorRecordedPlan ) {
diff --git a/db/queryutil.h b/db/queryutil.h
index 323bfd8c788..edf33a212a8 100644
--- a/db/queryutil.h
+++ b/db/queryutil.h
@@ -24,7 +24,7 @@ namespace mongo {
class FieldBound {
public:
- FieldBound( const BSONElement &e = emptyObj.firstElement() );
+ FieldBound( const BSONElement &e = BSONObj().firstElement() );
const FieldBound &operator&=( const FieldBound &other );
BSONElement lower() const { return lower_; }
BSONElement upper() const { return upper_; }
@@ -145,7 +145,7 @@ namespace mongo {
return false;
return true;
}
- QueryPattern pattern( const BSONObj &sort = emptyObj ) const;
+ QueryPattern pattern( const BSONObj &sort = BSONObj() ) const;
private:
static FieldBound *trivialBound_;
static FieldBound &trivialBound();
diff --git a/db/repl.cpp b/db/repl.cpp
index 15c49c52a79..536045052ed 100644
--- a/db/repl.cpp
+++ b/db/repl.cpp
@@ -519,7 +519,7 @@ namespace mongo {
// --source <host> specified.
// check that no items are in sources other than that
// add if missing
- auto_ptr<Cursor> c = findTableScan("local.sources", emptyObj);
+ auto_ptr<Cursor> c = findTableScan("local.sources", BSONObj());
int n = 0;
while ( c->ok() ) {
n++;
@@ -552,7 +552,7 @@ namespace mongo {
}
setClient("local.sources");
- auto_ptr<Cursor> c = findTableScan("local.sources", emptyObj);
+ auto_ptr<Cursor> c = findTableScan("local.sources", BSONObj());
while ( c->ok() ) {
ReplSource tmp(c->current());
if ( replPair && tmp.hostName == replPair->remote && tmp.sourceName() == "main" ) {
@@ -1076,7 +1076,7 @@ namespace mongo {
NamespaceDetails *localOplogMainDetails = 0;
Database *localOplogClient = 0;
- void logOp(const char *opstr, const char *ns, BSONObj& obj, BSONObj *patt, bool *b) {
+ void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt, bool *b) {
if ( master )
_logOp(opstr, ns, "local.oplog.$main", obj, patt, b);
NamespaceDetailsTransient &t = NamespaceDetailsTransient::get( ns );
@@ -1105,7 +1105,7 @@ namespace mongo {
when set, indicates this is the first thing we have logged for this database.
thus, the slave does not need to copy down all the data when it sees this.
*/
- void _logOp(const char *opstr, const char *ns, const char *logNS, BSONObj& obj, BSONObj *o2, bool *bb) {
+ void _logOp(const char *opstr, const char *ns, const char *logNS, const BSONObj& obj, BSONObj *o2, bool *bb) {
if ( strncmp(ns, "local.", 6) == 0 )
return;
@@ -1318,7 +1318,7 @@ namespace mongo {
string dbname = string(f.c_str(), f.size() - 2);
if ( dbname != "local." ) {
setClientTempNs(dbname.c_str());
- logOp("db", dbname.c_str(), emptyObj);
+ logOp("db", dbname.c_str(), BSONObj());
}
}
i++;
diff --git a/db/repl.h b/db/repl.h
index 171c41de3a0..abbeeb8346a 100644
--- a/db/repl.h
+++ b/db/repl.h
@@ -194,7 +194,7 @@ namespace mongo {
"c" db cmd
"db" declares presence of a database (ns is set to the db name + '.')
*/
- void _logOp(const char *opstr, const char *ns, const char *logNs, BSONObj& obj, BSONObj *patt, bool *b);
- void logOp(const char *opstr, const char *ns, BSONObj& obj, BSONObj *patt = 0, bool *b = 0);
+ void _logOp(const char *opstr, const char *ns, const char *logNs, const BSONObj& obj, BSONObj *patt, bool *b);
+ void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt = 0, bool *b = 0);
} // namespace mongo
diff --git a/dbtests/jsobjtests.cpp b/dbtests/jsobjtests.cpp
index 2bd06edd9f8..45ca4938143 100644
--- a/dbtests/jsobjtests.cpp
+++ b/dbtests/jsobjtests.cpp
@@ -168,8 +168,8 @@ namespace JsobjTests {
ASSERT( !invalid().valid() );
}
protected:
- virtual BSONObj valid() const { return emptyObj; }
- virtual BSONObj invalid() const { return emptyObj; }
+ virtual BSONObj valid() const { return BSONObj(); }
+ virtual BSONObj invalid() const { return BSONObj(); }
static char get( const BSONObj &o, int i ) {
return o.objdata()[ i ];
}
diff --git a/dbtests/jsontests.cpp b/dbtests/jsontests.cpp
index 5df54f5161f..dfcf617a1a2 100644
--- a/dbtests/jsontests.cpp
+++ b/dbtests/jsontests.cpp
@@ -30,7 +30,7 @@ namespace JsonTests {
class Empty {
public:
void run() {
- ASSERT_EQUALS( "{}", emptyObj.jsonString( Strict ) );
+ ASSERT_EQUALS( "{}", BSONObj().jsonString( Strict ) );
}
};
diff --git a/dbtests/pairingtests.cpp b/dbtests/pairingtests.cpp
index 91e598e55aa..f4d2efdb536 100644
--- a/dbtests/pairingtests.cpp
+++ b/dbtests/pairingtests.cpp
@@ -188,7 +188,7 @@ namespace PairingTests {
rp1.arbitrate();
ASSERT( rp1.state == ReplPair::State_Master );
- TestableReplPair rp2( false, emptyObj );
+ TestableReplPair rp2( false, BSONObj() );
rp2.arbitrate();
ASSERT( rp2.state == ReplPair::State_CantArb );
diff --git a/dbtests/perf/perftest.cpp b/dbtests/perf/perftest.cpp
index 530ca3ff308..a9bbf5bdfc9 100644
--- a/dbtests/perf/perftest.cpp
+++ b/dbtests/perf/perftest.cpp
@@ -411,7 +411,7 @@ namespace QueryTests {
}
void run() {
auto_ptr< DBClientCursor > c =
- client_->query( ns_.c_str(), Query( emptyObj ).sort( BSON( "_id" << 1 ) ) );
+ client_->query( ns_.c_str(), Query( BSONObj() ).sort( BSON( "_id" << 1 ) ) );
int i = 0;
for( ; c->more(); c->nextSafe(), ++i );
ASSERT_EQUALS( 50000, i );
@@ -427,7 +427,7 @@ namespace QueryTests {
}
void run() {
auto_ptr< DBClientCursor > c =
- client_->query( ns_.c_str(), Query( emptyObj ).sort( BSON( "_id" << 1 ) ) );
+ client_->query( ns_.c_str(), Query( BSONObj() ).sort( BSON( "_id" << 1 ) ) );
int i = 0;
for( ; c->more(); c->nextSafe(), ++i );
ASSERT_EQUALS( 50000, i );
@@ -518,7 +518,7 @@ namespace Plan {
}
void run() {
for( int i = 0; i < 10000; ++i )
- QueryPlanSet s( ns_.c_str(), emptyObj, emptyObj, &hintElt_ );
+ QueryPlanSet s( ns_.c_str(), BSONObj(), BSONObj(), &hintElt_ );
}
string ns_;
auto_ptr< dblock > lk_;
@@ -539,7 +539,7 @@ namespace Plan {
}
void run() {
for( int i = 0; i < 10000; ++i )
- QueryPlanSet s( ns_.c_str(), emptyObj, BSON( "a" << 1 ) );
+ QueryPlanSet s( ns_.c_str(), BSONObj(), BSON( "a" << 1 ) );
}
string ns_;
auto_ptr< dblock > lk_;
@@ -558,7 +558,7 @@ namespace Plan {
}
void run() {
for( int i = 0; i < 10000; ++i )
- QueryPlanSet s( ns_.c_str(), BSON( "a" << 1 ), emptyObj );
+ QueryPlanSet s( ns_.c_str(), BSON( "a" << 1 ), BSONObj() );
}
string ns_;
auto_ptr< dblock > lk_;
diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp
index 27deaf248ee..1dc63da9a20 100644
--- a/dbtests/queryoptimizertests.cpp
+++ b/dbtests/queryoptimizertests.cpp
@@ -56,7 +56,7 @@ namespace QueryOptimizerTests {
};
class Empty : public Base {
- virtual BSONObj query() { return emptyObj; }
+ virtual BSONObj query() { return BSONObj(); }
};
class Eq : public Base {
@@ -217,7 +217,7 @@ namespace QueryOptimizerTests {
ASSERT( p( BSON( "a" << 1 ), BSON( "b" << 1 ) ) != p( BSON( "a" << 4 ), BSON( "b" << 1 << "c" << 1 ) ) );
}
private:
- static QueryPattern p( const BSONObj &query, const BSONObj &sort = emptyObj ) {
+ static QueryPattern p( const BSONObj &query, const BSONObj &sort = BSONObj() ) {
return FieldBoundSet( "", query ).pattern( sort );
}
};
@@ -237,7 +237,7 @@ namespace QueryOptimizerTests {
Base() : indexNum_( 0 ) {
setClient( ns() );
string err;
- userCreateNS( ns(), emptyObj, err, false );
+ userCreateNS( ns(), BSONObj(), err, false );
}
~Base() {
if ( !nsd() )
@@ -272,13 +272,13 @@ namespace QueryOptimizerTests {
// There's a limit of 10 indexes total, make sure not to exceed this in a given test.
#define INDEX(x) this->index( BSON(x) )
- FieldBoundSet FieldBoundSet_GLOBAL( "", emptyObj );
-#define FBS(x) ( FieldBoundSet_GLOBAL = FieldBoundSet( ns(), x ) )
+ auto_ptr< FieldBoundSet > FieldBoundSet_GLOBAL;
+#define FBS(x) ( FieldBoundSet_GLOBAL.reset( new FieldBoundSet( ns(), x ) ), *FieldBoundSet_GLOBAL )
class NoIndex : public Base {
public:
void run() {
- QueryPlan p( FBS( emptyObj ), emptyObj, 0 );
+ QueryPlan p( FBS( BSONObj() ), BSONObj(), 0 );
ASSERT( !p.optimal() );
ASSERT( !p.scanAndOrderRequired() );
ASSERT( !p.keyMatch() );
@@ -296,13 +296,13 @@ namespace QueryOptimizerTests {
b2.appendMaxKey( "" );
BSONObj end = b2.obj();
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
ASSERT( !p.scanAndOrderRequired() );
ASSERT( !p.startKey().woCompare( start ) );
ASSERT( !p.endKey().woCompare( end ) );
- QueryPlan p2( FBS( emptyObj ), BSON( "a" << 1 << "b" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p2( FBS( BSONObj() ), BSON( "a" << 1 << "b" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( !p2.scanAndOrderRequired() );
- QueryPlan p3( FBS( emptyObj ), BSON( "b" << 1 ), INDEX( "a" << 1 ) );
+ QueryPlan p3( FBS( BSONObj() ), BSON( "b" << 1 ), INDEX( "a" << 1 ) );
ASSERT( p3.scanAndOrderRequired() );
ASSERT( !p3.startKey().woCompare( start ) );
ASSERT( !p3.endKey().woCompare( end ) );
@@ -312,7 +312,7 @@ namespace QueryOptimizerTests {
class MoreIndexThanNeeded : public Base {
public:
void run() {
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( !p.scanAndOrderRequired() );
}
};
@@ -320,10 +320,10 @@ namespace QueryOptimizerTests {
class IndexSigns : public Base {
public:
void run() {
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << 1 << "b" << -1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << 1 << "b" << -1 ) );
ASSERT( !p.scanAndOrderRequired() );
ASSERT_EQUALS( 1, p.direction() );
- QueryPlan p2( FBS( emptyObj ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p2( FBS( BSONObj() ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( p2.scanAndOrderRequired() );
ASSERT_EQUALS( 0, p2.direction() );
}
@@ -340,15 +340,15 @@ namespace QueryOptimizerTests {
b2.appendMaxKey( "" );
b2.appendMinKey( "" );
BSONObj end = b2.obj();
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << -1 << "b" << 1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 << "b" << -1 ), INDEX( "a" << -1 << "b" << 1 ) );
ASSERT( !p.scanAndOrderRequired() );
ASSERT_EQUALS( -1, p.direction() );
ASSERT( !p.startKey().woCompare( start ) );
ASSERT( !p.endKey().woCompare( end ) );
- QueryPlan p2( FBS( emptyObj ), BSON( "a" << -1 << "b" << -1 ), INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p2( FBS( BSONObj() ), BSON( "a" << -1 << "b" << -1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( !p2.scanAndOrderRequired() );
ASSERT_EQUALS( -1, p2.direction() );
- QueryPlan p3( FBS( emptyObj ), BSON( "a" << -1 << "b" << -1 ), INDEX( "a" << 1 << "b" << -1 ) );
+ QueryPlan p3( FBS( BSONObj() ), BSON( "a" << -1 << "b" << -1 ), INDEX( "a" << 1 << "b" << -1 ) );
ASSERT( p3.scanAndOrderRequired() );
ASSERT_EQUALS( 0, p3.direction() );
}
@@ -365,7 +365,7 @@ namespace QueryOptimizerTests {
b2.append( "", 3 );
b2.appendMaxKey( "" );
BSONObj end = b2.obj();
- QueryPlan p( FBS( BSON( "a" << 3 ) ), emptyObj, INDEX( "a" << -1 << "b" << 1 ) );
+ QueryPlan p( FBS( BSON( "a" << 3 ) ), BSONObj(), INDEX( "a" << -1 << "b" << 1 ) );
ASSERT( !p.scanAndOrderRequired() );
ASSERT( !p.startKey().woCompare( start ) );
ASSERT( !p.endKey().woCompare( end ) );
@@ -391,9 +391,9 @@ namespace QueryOptimizerTests {
class Optimal : public Base {
public:
void run() {
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
ASSERT( p.optimal() );
- QueryPlan p2( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p2( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( p2.optimal() );
QueryPlan p3( FBS( BSON( "a" << 1 ) ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( p3.optimal() );
@@ -409,7 +409,7 @@ namespace QueryOptimizerTests {
ASSERT( p8.optimal() );
QueryPlan p9( FBS( BSON( "a" << 1 << "b" << LT << 1 ) ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
ASSERT( p9.optimal() );
- QueryPlan p10( FBS( BSON( "a" << 1 ) ), emptyObj, INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
+ QueryPlan p10( FBS( BSON( "a" << 1 ) ), BSONObj(), INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
ASSERT( p10.optimal() );
}
};
@@ -417,9 +417,9 @@ namespace QueryOptimizerTests {
class MoreOptimal : public Base {
public:
void run() {
- QueryPlan p11( FBS( BSON( "a" << 1 << "b" << LT << 1 ) ), emptyObj, INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
+ QueryPlan p11( FBS( BSON( "a" << 1 << "b" << LT << 1 ) ), BSONObj(), INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
ASSERT( p11.optimal() );
- QueryPlan p12( FBS( BSON( "a" << LT << 1 ) ), emptyObj, INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
+ QueryPlan p12( FBS( BSON( "a" << LT << 1 ) ), BSONObj(), INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
ASSERT( p12.optimal() );
QueryPlan p13( FBS( BSON( "a" << LT << 1 ) ), BSON( "a" << 1 ), INDEX( "a" << 1 << "b" << 1 << "c" << 1 ) );
ASSERT( p13.optimal() );
@@ -429,10 +429,10 @@ namespace QueryOptimizerTests {
class KeyMatch : public Base {
public:
void run() {
- QueryPlan p( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
+ QueryPlan p( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
ASSERT( p.keyMatch() );
ASSERT( p.exactKeyMatch() );
- QueryPlan p2( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "b" << 1 << "a" << 1 ) );
+ QueryPlan p2( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "b" << 1 << "a" << 1 ) );
ASSERT( p2.keyMatch() );
ASSERT( p2.exactKeyMatch() );
QueryPlan p3( FBS( BSON( "b" << "z" ) ), BSON( "a" << 1 ), INDEX( "b" << 1 << "a" << 1 ) );
@@ -441,13 +441,13 @@ namespace QueryOptimizerTests {
QueryPlan p4( FBS( BSON( "c" << "y" << "b" << "z" ) ), BSON( "a" << 1 ), INDEX( "b" << 1 << "a" << 1 << "c" << 1 ) );
ASSERT( p4.keyMatch() );
ASSERT( p4.exactKeyMatch() );
- QueryPlan p5( FBS( BSON( "c" << "y" << "b" << "z" ) ), emptyObj, INDEX( "b" << 1 << "a" << 1 << "c" << 1 ) );
+ QueryPlan p5( FBS( BSON( "c" << "y" << "b" << "z" ) ), BSONObj(), INDEX( "b" << 1 << "a" << 1 << "c" << 1 ) );
ASSERT( p5.keyMatch() );
ASSERT( p5.exactKeyMatch() );
- QueryPlan p6( FBS( BSON( "c" << LT << "y" << "b" << GT << "z" ) ), emptyObj, INDEX( "b" << 1 << "a" << 1 << "c" << 1 ) );
+ QueryPlan p6( FBS( BSON( "c" << LT << "y" << "b" << GT << "z" ) ), BSONObj(), INDEX( "b" << 1 << "a" << 1 << "c" << 1 ) );
ASSERT( p6.keyMatch() );
ASSERT( !p6.exactKeyMatch() );
- QueryPlan p7( FBS( emptyObj ), BSON( "a" << 1 ), INDEX( "b" << 1 ) );
+ QueryPlan p7( FBS( BSONObj() ), BSON( "a" << 1 ), INDEX( "b" << 1 ) );
ASSERT( !p7.keyMatch() );
ASSERT( !p7.exactKeyMatch() );
QueryPlan p8( FBS( BSON( "d" << "y" ) ), BSON( "a" << 1 ), INDEX( "a" << 1 ) );
@@ -459,17 +459,17 @@ namespace QueryOptimizerTests {
class ExactKeyQueryTypes : public Base {
public:
void run() {
- QueryPlan p( FBS( BSON( "a" << "b" ) ), emptyObj, INDEX( "a" << 1 ) );
+ QueryPlan p( FBS( BSON( "a" << "b" ) ), BSONObj(), INDEX( "a" << 1 ) );
ASSERT( p.exactKeyMatch() );
- QueryPlan p2( FBS( BSON( "a" << 4 ) ), emptyObj, INDEX( "a" << 1 ) );
+ QueryPlan p2( FBS( BSON( "a" << 4 ) ), BSONObj(), INDEX( "a" << 1 ) );
ASSERT( !p2.exactKeyMatch() );
- QueryPlan p3( FBS( BSON( "a" << BSON( "c" << "d" ) ) ), emptyObj, INDEX( "a" << 1 ) );
+ QueryPlan p3( FBS( BSON( "a" << BSON( "c" << "d" ) ) ), BSONObj(), INDEX( "a" << 1 ) );
ASSERT( !p3.exactKeyMatch() );
BSONObjBuilder b;
b.appendRegex( "a", "^ddd" );
- QueryPlan p4( FBS( b.obj() ), emptyObj, INDEX( "a" << 1 ) );
+ QueryPlan p4( FBS( b.obj() ), BSONObj(), INDEX( "a" << 1 ) );
ASSERT( !p4.exactKeyMatch() );
- QueryPlan p5( FBS( BSON( "a" << "z" << "b" << 4 ) ), emptyObj, INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p5( FBS( BSON( "a" << "z" << "b" << 4 ) ), BSONObj(), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( !p5.exactKeyMatch() );
}
};
@@ -477,7 +477,7 @@ namespace QueryOptimizerTests {
class Unhelpful : public Base {
public:
void run() {
- QueryPlan p( FBS( BSON( "b" << 1 ) ), emptyObj, INDEX( "a" << 1 << "b" << 1 ) );
+ QueryPlan p( FBS( BSON( "b" << 1 ) ), BSONObj(), INDEX( "a" << 1 << "b" << 1 ) );
ASSERT( p.keyMatch() );
ASSERT( !p.bound( "a" ).nontrivial() );
ASSERT( !p.unhelpful() );
@@ -486,11 +486,11 @@ namespace QueryOptimizerTests {
ASSERT( !p2.scanAndOrderRequired() );
ASSERT( !p2.bound( "a" ).nontrivial() );
ASSERT( !p2.unhelpful() );
- QueryPlan p3( FBS( BSON( "b" << 1 << "c" << 1 ) ), emptyObj, INDEX( "b" << 1 ) );
+ QueryPlan p3( FBS( BSON( "b" << 1 << "c" << 1 ) ), BSONObj(), INDEX( "b" << 1 ) );
ASSERT( !p3.keyMatch() );
ASSERT( p3.bound( "b" ).nontrivial() );
ASSERT( !p3.unhelpful() );
- QueryPlan p4( FBS( BSON( "c" << 1 << "d" << 1 ) ), emptyObj, INDEX( "b" << 1 << "c" << 1 ) );
+ QueryPlan p4( FBS( BSON( "c" << 1 << "d" << 1 ) ), BSONObj(), INDEX( "b" << 1 << "c" << 1 ) );
ASSERT( !p4.keyMatch() );
ASSERT( !p4.bound( "b" ).nontrivial() );
ASSERT( p4.unhelpful() );
@@ -505,7 +505,7 @@ namespace QueryOptimizerTests {
Base() {
setClient( ns() );
string err;
- userCreateNS( ns(), emptyObj, err, false );
+ userCreateNS( ns(), BSONObj(), err, false );
AuthenticationInfo *ai = new AuthenticationInfo();
authInfo.reset( ai );
}
@@ -550,7 +550,7 @@ namespace QueryOptimizerTests {
void run() {
Helpers::ensureIndex( ns(), BSON( "a" << 1 ), "a_1" );
Helpers::ensureIndex( ns(), BSON( "a" << 1 ), "b_2" );
- QueryPlanSet s( ns(), BSON( "a" << 4 ), emptyObj );
+ QueryPlanSet s( ns(), BSON( "a" << 4 ), BSONObj() );
ASSERT_EQUALS( 1, s.nPlans() );
}
};
@@ -570,7 +570,7 @@ namespace QueryOptimizerTests {
void run() {
Helpers::ensureIndex( ns(), BSON( "a" << 1 ), "a_1" );
Helpers::ensureIndex( ns(), BSON( "b" << 1 ), "b_1" );
- QueryPlanSet s( ns(), emptyObj, emptyObj );
+ QueryPlanSet s( ns(), BSONObj(), BSONObj() );
ASSERT_EQUALS( 1, s.nPlans() );
}
};
@@ -646,10 +646,10 @@ namespace QueryOptimizerTests {
ASSERT_EQUALS( 1, runCount( ns(), BSON( "query" << BSON( "a" << 4 ) ), err ) );
theDataFileMgr.insert( ns(), four );
ASSERT_EQUALS( 2, runCount( ns(), BSON( "query" << BSON( "a" << 4 ) ), err ) );
- ASSERT_EQUALS( 3, runCount( ns(), BSON( "query" << emptyObj ), err ) );
+ ASSERT_EQUALS( 3, runCount( ns(), BSON( "query" << BSONObj() ), err ) );
ASSERT_EQUALS( 3, runCount( ns(), BSON( "query" << BSON( "a" << GT << 0 ) ), err ) );
// missing ns
- ASSERT_EQUALS( -1, runCount( "missingNS", emptyObj, err ) );
+ ASSERT_EQUALS( -1, runCount( "missingNS", BSONObj(), err ) );
// impossible match
ASSERT_EQUALS( 0, runCount( ns(), BSON( "query" << BSON( "a" << GT << 0 << LT << -1 ) ), err ) );
}
@@ -659,7 +659,7 @@ namespace QueryOptimizerTests {
public:
void run() {
Message m;
- assembleRequest( "missingNS", emptyObj, 0, 0, 0, 0, m );
+ assembleRequest( "missingNS", BSONObj(), 0, 0, 0, 0, m );
stringstream ss;
ASSERT_EQUALS( 0, runQuery( m, ss )->nReturned );
}
@@ -670,7 +670,7 @@ namespace QueryOptimizerTests {
void run() {
Helpers::ensureIndex( ns(), BSON( "a" << 1 ), "a_1" );
Helpers::ensureIndex( ns(), BSON( "b" << 1 ), "b_1" );
- QueryPlanSet s( ns(), BSON( "a" << 1 << "c" << 2 ), emptyObj );
+ QueryPlanSet s( ns(), BSON( "a" << 1 << "c" << 2 ), BSONObj() );
ASSERT_EQUALS( 2, s.nPlans() );
}
};
diff --git a/dbtests/querytests.cpp b/dbtests/querytests.cpp
index f6d3d29e8af..078f6c29fee 100644
--- a/dbtests/querytests.cpp
+++ b/dbtests/querytests.cpp
@@ -169,37 +169,37 @@ namespace QueryTests {
class ModId : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{$set:{'_id':4}}" ) );
+ update( ns(), BSONObj(), fromjson( "{$set:{'_id':4}}" ) );
}
};
class ModNonmodMix : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{$set:{a:4},z:3}" ) );
+ update( ns(), BSONObj(), fromjson( "{$set:{a:4},z:3}" ) );
}
};
class InvalidMod : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{$awk:{a:4}}" ) );
+ update( ns(), BSONObj(), fromjson( "{$awk:{a:4}}" ) );
}
};
class ModNotFirst : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{z:3,$set:{a:4}}" ) );
+ update( ns(), BSONObj(), fromjson( "{z:3,$set:{a:4}}" ) );
}
};
class ModDuplicateFieldSpec : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{$set:{a:4},$inc:{a:1}}" ) );
+ update( ns(), BSONObj(), fromjson( "{$set:{a:4},$inc:{a:1}}" ) );
}
};
class IncNonNumber : public Fail {
void doIt() {
- update( ns(), emptyObj, fromjson( "{$inc:{a:'d'}}" ) );
+ update( ns(), BSONObj(), fromjson( "{$inc:{a:'d'}}" ) );
}
};
@@ -234,7 +234,7 @@ namespace QueryTests {
insert( ns, BSON( "a" << 1 ) );
insert( ns, BSON( "a" << 2 ) );
insert( ns, BSON( "a" << 3 ) );
- auto_ptr< DBClientCursor > cursor = client().query( ns, emptyObj, 2 );
+ auto_ptr< DBClientCursor > cursor = client().query( ns, BSONObj(), 2 );
long long cursorId = cursor->getCursorId();
cursor->decouple();
cursor.reset();
@@ -398,7 +398,7 @@ namespace QueryTests {
public:
void run() {
client().insert( ns(), BSON( "a" << "b" ) );
- client().update( ns(), emptyObj, BSON( "$set" << BSON( "a" << 5 ) ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a" << 5 ) ) );
ASSERT( !client().findOne( ns(), BSON( "a" << 5 ) ).isEmpty() );
}
};
@@ -407,7 +407,7 @@ namespace QueryTests {
public:
void run() {
client().insert( ns(), BSON( "a" << "bcd" ) );
- client().update( ns(), emptyObj, BSON( "$set" << BSON( "a" << 5.0 ) ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a" << 5.0 ) ) );
ASSERT( !client().findOne( ns(), BSON( "a" << 5.0 ) ).isEmpty() );
}
};
@@ -416,9 +416,9 @@ namespace QueryTests {
public:
void run() {
client().insert( ns(), fromjson( "{a:{b:4}}" ) );
- client().update( ns(), emptyObj, BSON( "$inc" << BSON( "a.b" << 10 ) ) );
+ client().update( ns(), BSONObj(), BSON( "$inc" << BSON( "a.b" << 10 ) ) );
ASSERT( !client().findOne( ns(), BSON( "a.b" << 14 ) ).isEmpty() );
- client().update( ns(), emptyObj, BSON( "$set" << BSON( "a.b" << 55 ) ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << 55 ) ) );
ASSERT( !client().findOne( ns(), BSON( "a.b" << 55 ) ).isEmpty() );
}
};
@@ -427,8 +427,8 @@ namespace QueryTests {
public:
void run() {
client().insert( ns(), fromjson( "{a:{b:'cdef'}}" ) );
- client().update( ns(), emptyObj, BSON( "$set" << BSON( "a.b" << "llll" ) ) );
- out() << "one: " << client().findOne( ns(), emptyObj ) << endl;
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << "llll" ) ) );
+ out() << "one: " << client().findOne( ns(), BSONObj() ) << endl;
ASSERT( !client().findOne( ns(), BSON( "a.b" << "llll" ) ).isEmpty() );
}
};
@@ -437,7 +437,7 @@ namespace QueryTests {
// public:
// void run() {
// client().insert( ns(), fromjson( "{a:{b:'cdef'}}" ) );
-// client().update( ns(), emptyObj, BSON( "$set" << BSON( "a.b" << "lllll" ) ) );
+// client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << "lllll" ) ) );
// ASSERT( !client().findOne( ns(), BSON( "a.b" << "lllll" ) ).isEmpty() );
// }
// };
diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp
index 8c2c842eee9..0aa06ddda00 100644
--- a/dbtests/repltests.cpp
+++ b/dbtests/repltests.cpp
@@ -60,7 +60,7 @@ namespace ReplTests {
return "local.oplog.$main";
}
DBClientInterface *client() const { return &client_; }
- BSONObj one( const BSONObj &query = emptyObj ) const {
+ BSONObj one( const BSONObj &query = BSONObj() ) const {
return client()->findOne( ns(), query );
}
void checkOne( const BSONObj &o ) const {
@@ -81,7 +81,7 @@ namespace ReplTests {
ASSERT( !expected.woCompare( got ) );
}
BSONObj oneOp() const {
- return client()->findOne( logNs(), emptyObj );
+ return client()->findOne( logNs(), BSONObj() );
}
int count() const {
int count = 0;
diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj
index 37ab05aa994..c9f872232c2 100644
--- a/mongo.xcodeproj/project.pbxproj
+++ b/mongo.xcodeproj/project.pbxproj
@@ -21,6 +21,15 @@
9302D9A00F30AB8C00DFA4EF /* ShellUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShellUtils.h; sourceTree = "<group>"; };
9302D9A20F30AB8C00DFA4EF /* utils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = utils.js; sourceTree = "<group>"; };
931A027A0F58AA4400147C0E /* jsobjmanipulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsobjmanipulator.h; sourceTree = "<group>"; };
+ 93278F570F72D32900844664 /* gridfs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gridfs.cpp; sourceTree = "<group>"; };
+ 93278F580F72D32900844664 /* gridfs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gridfs.h; sourceTree = "<group>"; };
+ 93278F610F72D39400844664 /* cursors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cursors.cpp; sourceTree = "<group>"; };
+ 93278F620F72D39400844664 /* cursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cursors.h; sourceTree = "<group>"; };
+ 93278F630F72D39400844664 /* d_logic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = d_logic.cpp; sourceTree = "<group>"; };
+ 93278F640F72D39400844664 /* d_logic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = d_logic.h; sourceTree = "<group>"; };
+ 93278F650F72D39400844664 /* strategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strategy.cpp; sourceTree = "<group>"; };
+ 93278F660F72D39400844664 /* strategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strategy.h; sourceTree = "<group>"; };
+ 93278F670F72D39400844664 /* strategy_shard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strategy_shard.cpp; sourceTree = "<group>"; };
932AC3EB0F4A5B34005BF8B0 /* queryoptimizertests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = queryoptimizertests.cpp; sourceTree = "<group>"; };
932AC4310F4A5E9D005BF8B0 /* SConstruct */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SConstruct; sourceTree = "<group>"; };
933A4D130F55A68600145C4B /* authTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = authTest.cpp; sourceTree = "<group>"; };
@@ -321,6 +330,8 @@
9342232A0EF16D4F00608550 /* client */ = {
isa = PBXGroup;
children = (
+ 93278F570F72D32900844664 /* gridfs.cpp */,
+ 93278F580F72D32900844664 /* gridfs.h */,
933A4D120F55A68600145C4B /* examples */,
9342232B0EF16D4F00608550 /* connpool.cpp */,
9342232C0EF16D4F00608550 /* connpool.h */,
@@ -474,6 +485,13 @@
93A13A200F4620A500AF1B0D /* s */ = {
isa = PBXGroup;
children = (
+ 93278F610F72D39400844664 /* cursors.cpp */,
+ 93278F620F72D39400844664 /* cursors.h */,
+ 93278F630F72D39400844664 /* d_logic.cpp */,
+ 93278F640F72D39400844664 /* d_logic.h */,
+ 93278F650F72D39400844664 /* strategy.cpp */,
+ 93278F660F72D39400844664 /* strategy.h */,
+ 93278F670F72D39400844664 /* strategy_shard.cpp */,
93E727090F4B5B5B004F9B5D /* shardkey.cpp */,
93E7270A0F4B5B5B004F9B5D /* shardkey.h */,
93A13A210F4620A500AF1B0D /* commands.cpp */,
diff --git a/s/commands.cpp b/s/commands.cpp
index a7e449fc3bb..e92073ec50c 100644
--- a/s/commands.cpp
+++ b/s/commands.cpp
@@ -95,7 +95,7 @@ namespace mongo {
ScopedDbConnection conn( configServer.getPrimary() );
- auto_ptr<DBClientCursor> cursor = conn->query( "config.databases" , emptyObj );
+ auto_ptr<DBClientCursor> cursor = conn->query( "config.databases" , BSONObj() );
BSONObjBuilder list;
int num = 0;
@@ -416,7 +416,7 @@ namespace mongo {
ScopedDbConnection conn( configServer.getPrimary() );
vector<BSONObj> all;
- auto_ptr<DBClientCursor> cursor = conn->query( "config.servers" , emptyObj );
+ auto_ptr<DBClientCursor> cursor = conn->query( "config.servers" , BSONObj() );
while ( cursor->more() ){
BSONObj o = cursor->next();
all.push_back( o );
diff --git a/s/cursors.cpp b/s/cursors.cpp
index cf21990b4be..4c9e94feecc 100644
--- a/s/cursors.cpp
+++ b/s/cursors.cpp
@@ -26,7 +26,7 @@ namespace mongo {
_fields = b.obj();
}
else {
- _fields = emptyObj;
+ _fields = BSONObj();
}
do {
@@ -195,7 +195,7 @@ namespace mongo {
BSONObj ParallelSortShardedCursor::next(){
advance();
- BSONObj best = emptyObj;
+ BSONObj best = BSONObj();
int bestFrom = -1;
for ( int i=0; i<_numServers; i++){
@@ -217,7 +217,7 @@ namespace mongo {
}
uassert( "no more elements" , ! best.isEmpty() );
- _nexts[bestFrom] = emptyObj;
+ _nexts[bestFrom] = BSONObj();
return best;
}
diff --git a/s/cursors.h b/s/cursors.h
index b8e46d94950..482edb6155b 100644
--- a/s/cursors.h
+++ b/s/cursors.h
@@ -29,7 +29,7 @@ namespace mongo {
bool sendNextBatch( Request& r , int ntoreturn );
protected:
- auto_ptr<DBClientCursor> query( const string& server , int num = 0 , BSONObj extraFilter = emptyObj );
+ auto_ptr<DBClientCursor> query( const string& server , int num = 0 , BSONObj extraFilter = BSONObj() );
BSONObj concatQuery( const BSONObj& query , const BSONObj& extraFilter );
BSONObj _concatFilter( const BSONObj& filter , const BSONObj& extraFilter );
@@ -51,7 +51,7 @@ namespace mongo {
class ServerAndQuery {
public:
- ServerAndQuery( const string& server , BSONObj extra = emptyObj , BSONObj orderObject = emptyObj ) :
+ ServerAndQuery( const string& server , BSONObj extra = BSONObj() , BSONObj orderObject = BSONObj() ) :
_server( server ) , _extra( extra.getOwned() ) , _orderObject( orderObject.getOwned() ){
}
diff --git a/s/shardkey.h b/s/shardkey.h
index fb4f7392173..40253241a2b 100644
--- a/s/shardkey.h
+++ b/s/shardkey.h
@@ -29,7 +29,7 @@ namespace mongo {
*/
class ShardKeyPattern {
public:
- ShardKeyPattern( BSONObj p = emptyObj ) : pattern( p.getOwned() ) {
+ ShardKeyPattern( BSONObj p = BSONObj() ) : pattern( p.getOwned() ) {
pattern.getFieldNames(patternfields);
}
diff --git a/s/strategy_shard.cpp b/s/strategy_shard.cpp
index 12b9628f828..5f53af25baf 100644
--- a/s/strategy_shard.cpp
+++ b/s/strategy_shard.cpp
@@ -55,7 +55,7 @@ namespace mongo {
set<ServerAndQuery> buckets;
for ( vector<Shard*>::iterator i = shards.begin(); i != shards.end(); i++ ){
Shard * s = *i;
- BSONObj extra = emptyObj;
+ BSONObj extra = BSONObj();
if ( serverCounts[s->getServer()] > 1 ){
BSONObjBuilder b;
s->getFilter( b );
diff --git a/tools/dump.cpp b/tools/dump.cpp
index d0dd498e9bf..26604e15f0e 100644
--- a/tools/dump.cpp
+++ b/tools/dump.cpp
@@ -40,7 +40,7 @@ public:
int out = open( outputFile.string().c_str() , O_WRONLY | O_CREAT | O_TRUNC , 0666 );
assert( out );
- auto_ptr<DBClientCursor> cursor = _conn.query( coll.c_str() , emptyObj , 0 , 0 , 0 , Option_SlaveOk );
+ auto_ptr<DBClientCursor> cursor = _conn.query( coll.c_str() , BSONObj() , 0 , 0 , 0 , Option_SlaveOk );
int num = 0;
while ( cursor->more() ) {
@@ -61,7 +61,7 @@ public:
string sns = db + ".system.namespaces";
- auto_ptr<DBClientCursor> cursor = _conn.query( sns.c_str() , emptyObj , 0 , 0 , 0 , Option_SlaveOk );
+ auto_ptr<DBClientCursor> cursor = _conn.query( sns.c_str() , BSONObj() , 0 , 0 , 0 , Option_SlaveOk );
while ( cursor->more() ) {
BSONObj obj = cursor->next();
if ( obj.toString().find( ".$" ) != string::npos )