summaryrefslogtreecommitdiff
path: root/db/mr.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-10-02 15:43:30 -0400
committerEliot Horowitz <eliot@10gen.com>2009-10-02 15:43:30 -0400
commit9b0f12bb1edffebba7bf05321352eedb393d7f1a (patch)
tree63490a8e3288e34ce70d3966d6af77a9ab9c5dca /db/mr.cpp
parentbefa6fb41fa710f527b22b1521f1b5b25a454f93 (diff)
downloadmongo-9b0f12bb1edffebba7bf05321352eedb393d7f1a.tar.gz
use _id for M/R output table - saves space and an index
Diffstat (limited to 'db/mr.cpp')
-rw-r--r--db/mr.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/db/mr.cpp b/db/mr.cpp
index d0a7cb74ed4..066ade2516d 100644
--- a/db/mr.cpp
+++ b/db/mr.cpp
@@ -48,9 +48,9 @@ namespace mongo {
for ( list<BSONObj>::iterator i=values.begin(); i!=values.end(); i++){
BSONObj o = *i;
if ( n == 0 ){
- reduceArgs.append( o["key"] );
+ reduceArgs.append( o["_id"] );
BSONObjBuilder temp;
- temp.append( o["key"] );
+ temp.append( o["_id"] );
key = temp.obj();
}
valueBuilder.appendAs( o["value"] , BSONObjBuilder::numStr( n++ ).c_str() );
@@ -65,7 +65,7 @@ namespace mongo {
return BSONObj();
}
BSONObjBuilder b;
- b.append( key["key"] );
+ b.append( key["_id"] );
s->append( b , "value" , "return" );
return b.obj();
}
@@ -180,7 +180,7 @@ namespace mongo {
{
assert( i.more() );
BSONObjBuilder b;
- b.appendAs( i.next() , "key" );
+ b.appendAs( i.next() , "_id" );
key = b.obj();
}
@@ -224,7 +224,7 @@ namespace mongo {
if ( values.size() == 0 )
return;
- BSONObj key = values.begin()->extractFields( BSON( "key" << 1 ) );
+ BSONObj key = values.begin()->extractFields( BSON( "_id" << 1 ) );
if ( values.size() == 1 ){
assert( db.count( resultColl , key ) == 1 );
@@ -259,7 +259,6 @@ namespace mongo {
string finalOutputShort = finalOutput.substr( database->name.size() + 1 );
log(1) << "\t resultColl: " << resultColl << " short: " << resultCollShort << endl;
db.dropCollection( resultColl );
- db.ensureIndex( resultColl , BSON( "key" << 1 ) );
int num = 0;
@@ -305,9 +304,9 @@ namespace mongo {
BSONObj prev;
list<BSONObj> all;
- BSONObj sortKey = BSON( "key" << 1 );
+ BSONObj sortKey = BSON( "_id" << 1 );
- cursor = db.query( resultColl, Query().sort( BSON( "key" << 1 ) ) );
+ cursor = db.query( resultColl, Query().sort( sortKey ) );
while ( cursor->more() ){
BSONObj o = cursor->next().getOwned();