summaryrefslogtreecommitdiff
path: root/s
diff options
context:
space:
mode:
authoragirbal <antoine@10gen.com>2011-06-13 16:19:31 -0700
committeragirbal <antoine@10gen.com>2011-06-13 16:19:31 -0700
commit6296e8c7633af418c4ff3e69b59e8c7597c0d1d1 (patch)
treed25fc8e25def57b59c3bf6e02c75da2ce1f4df4c /s
parentebd06a579b175aafbd28996dd6ec747dc056806e (diff)
downloadmongo-6296e8c7633af418c4ff3e69b59e8c7597c0d1d1.tar.gz
SERVER-2531: delete temp collection. Remove debug output.
Diffstat (limited to 's')
-rw-r--r--s/commands_public.cpp38
-rw-r--r--s/mr_shard.h2
2 files changed, 26 insertions, 14 deletions
diff --git a/s/commands_public.cpp b/s/commands_public.cpp
index bf6d7592d99..6adfa887dfb 100644
--- a/s/commands_public.cpp
+++ b/s/commands_public.cpp
@@ -1140,9 +1140,9 @@ namespace mongo {
mr_shard::BSONList values;
Strategy* s = SHARDED;
+ long long finalCount = 0;
while ( cursor.more() ) {
BSONObj t = cursor.next().getOwned();
- cout << t.toString() << endl;
if ( values.size() == 0 ) {
values.push_back( t );
@@ -1154,30 +1154,40 @@ namespace mongo {
continue;
}
- cout << "Doing sharded reduce on " << values.size() << " objects";
BSONObj final = config.reducer->finalReduce(values, config.finalizer.get());
s->insertSharded(conf, outns.c_str(), final, 0);
+ ++finalCount;
values.clear();
values.push_back( t );
}
if ( values.size() ) {
- cout << "Doing sharded reduce on " << values.size() << " objects";
- const BSONObj& final = config.reducer->finalReduce(values, config.finalizer.get());
- s->insertSharded(conf, outns.c_str(), (BSONObj&) final, 0);
+ BSONObj final = config.reducer->finalReduce(values, config.finalizer.get());
+ s->insertSharded(conf, outns.c_str(), final, 0);
+ ++finalCount;
}
-// state.dumpToInc();
-// state.postProcessCollection();
-// state.appendResults( result );
+ for ( set<ServerAndQuery>::iterator i=servers.begin(); i!=servers.end(); i++ ) {
+ ScopedDbConnection conn( i->_server );
+ conn->dropCollection( dbName + "." + shardedOutputCollection );
+ conn.done();
+ }
-// for ( set<ServerAndQuery>::iterator i=servers.begin(); i!=servers.end(); i++ ) {
-// ScopedDbConnection conn( i->_server );
-// conn->dropCollection( dbname + "." + shardedOutputCollection );
-// conn.done();
-// }
result.append("shardCounts", shardCounts);
- result.append("counts", aggCounts);
+
+ // fix the global counts
+ BSONObjBuilder countsB(32);
+ BSONObjIterator j(aggCounts);
+ while (j.more()) {
+ BSONElement elmt = j.next();
+ if (!strcmp(elmt.fieldName(), "reduce"))
+ countsB.append("reduce", elmt.numberLong() + state.numReduces());
+ else if (!strcmp(elmt.fieldName(), "output"))
+ countsB.append("output", finalCount);
+ else
+ countsB.append(elmt);
+ }
+ result.append( "counts" , countsB.obj() );
ok = true;
}
diff --git a/s/mr_shard.h b/s/mr_shard.h
index 9afabface0d..9603ba92cdc 100644
--- a/s/mr_shard.h
+++ b/s/mr_shard.h
@@ -216,6 +216,8 @@ namespace mongo {
const bool isOnDisk() { return _onDisk; }
+ long long numReduces() const { return _config.reducer->numReduces; }
+
const Config& _config;
protected: