summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-05-25 13:37:05 -0700
committerAaron <aaron@10gen.com>2010-05-25 13:37:05 -0700
commitb2a9ff3aeac23468b2008ff8c70cc5771c14d3cb (patch)
treec3910c222e28f26a5aff5cfe4d450bd41f006c8d
parentfa4e812db842a02cd53ddfa815011aacbee65f1c (diff)
downloadmongo-b2a9ff3aeac23468b2008ff8c70cc5771c14d3cb.tar.gz
SERVER-109 convert remaining dbcommands, fix clone as capped issue w/ getmore
-rw-r--r--db/dbcommands.cpp12
-rw-r--r--db/query.cpp3
-rw-r--r--jstests/or4.js2
3 files changed, 8 insertions, 9 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index 2db53d6a7da..50c29881498 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -882,13 +882,12 @@ namespace mongo {
BSONObj query = BSON( "files_id" << jsobj["filemd5"] );
BSONObj sort = BSON( "files_id" << 1 << "n" << 1 );
- shared_ptr<Cursor> cursor = MultiPlanScanner(ns.c_str(), query, sort).getBestGuess()->newCursor();
- scoped_ptr<CoveredIndexMatcher> matcher (new CoveredIndexMatcher(query, cursor->indexKeyPattern()));
+ shared_ptr<Cursor> cursor = bestGuessCursor(ns.c_str(), query, sort);
scoped_ptr<ClientCursor> cc (new ClientCursor(QueryOption_NoCursorTimeout, cursor, ns.c_str()));
int n = 0;
while ( cursor->ok() ){
- if ( ! matcher->matchesCurrent( cursor.get() ) ){
+ if ( ! cursor->matcher()->matchesCurrent( cursor.get() ) ){
log() << "**** NOT MATCHING ****" << endl;
PRINT(cursor->current());
cursor->advance();
@@ -1363,13 +1362,10 @@ namespace mongo {
map<BSONObj,int,BSONObjCmp> map;
list<BSONObj> blah;
- shared_ptr<Cursor> cursor = MultiPlanScanner(ns.c_str() , query , BSONObj() ).getBestGuess()->newCursor();
- auto_ptr<CoveredIndexMatcher> matcher;
- if ( ! query.isEmpty() )
- matcher.reset( new CoveredIndexMatcher( query , cursor->indexKeyPattern() ) );
+ shared_ptr<Cursor> cursor = bestGuessCursor(ns.c_str() , query , BSONObj() );
while ( cursor->ok() ){
- if ( matcher.get() && ! matcher->matchesCurrent( cursor.get() ) ){
+ if ( cursor->matcher() && ! cursor->matcher()->matchesCurrent( cursor.get() ) ){
cursor->advance();
continue;
}
diff --git a/db/query.cpp b/db/query.cpp
index 4c71e7823a3..16bc2e17c5e 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -325,7 +325,8 @@ namespace mongo {
cc = 0;
break;
}
- if ( !c->matcher()->matches(c->currKey(), c->currLoc() ) ) {
+ // in some cases (clone collection) there won't be a matcher
+ if ( c->matcher() && !c->matcher()->matches(c->currKey(), c->currLoc() ) ) {
}
else {
//out() << "matches " << c->currLoc().toString() << '\n';
diff --git a/jstests/or4.js b/jstests/or4.js
index d59bc843334..469cc8a9904 100644
--- a/jstests/or4.js
+++ b/jstests/or4.js
@@ -63,6 +63,8 @@ assert.eq.automsg( "4", "t.find( {$or:[{a:2},{b:3}]} ).snapshot().toArray().leng
t.save( {a:1,b:3} );
assert.eq.automsg( "[1,2]", "t.distinct( 'a', {$or:[{a:2},{b:3}]} )" );
+assert.eq.automsg( "[{a:2},{a:null},{a:1}]", "t.group( {key:{a:1}, cond:{$or:[{a:2},{b:3}]}, reduce:function( x, y ) { }, initial:{} } )" );
+
t.remove( {} );
t.save( {a:[1,2]} );