summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-11-03 18:37:31 -0400
committerEliot Horowitz <eliot@10gen.com>2010-11-03 18:57:19 -0400
commitd8bcfc55a937249b6782e40d92340586ae710c47 (patch)
tree2c2cef8005521b29ab0cfa096dfdd6d4316eefc6 /tools
parentb741e68528ecfc6bb06f82355db1d9d8d0c4c43a (diff)
downloadmongo-d8bcfc55a937249b6782e40d92340586ae710c47.tar.gz
--discover works for mongos now
Diffstat (limited to 'tools')
-rw-r--r--tools/stat.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp
index fd5b9d18319..af0a23c4856 100644
--- a/tools/stat.cpp
+++ b/tools/stat.cpp
@@ -569,6 +569,40 @@ namespace mongo {
biggest = rows[i].data;
}
+ { // check for any headers not in biggest
+
+ // TODO: we put any new headers at end,
+ // ideally we would interleave
+
+ set<string> seen;
+
+ BSONObjBuilder b;
+
+ { // iterate biggest
+ BSONObjIterator i( biggest );
+ while ( i.more() ){
+ BSONElement e = i.next();
+ seen.insert( e.fieldName() );
+ b.append( e );
+ }
+ }
+
+ // now do the rest
+ for ( unsigned j=0; j<rows.size(); j++ ){
+ BSONObjIterator i( rows[j].data );
+ while ( i.more() ){
+ BSONElement e = i.next();
+ if ( seen.count( e.fieldName() ) )
+ continue;
+ seen.insert( e.fieldName() );
+ b.append( e );
+ }
+
+ }
+
+ biggest = b.obj();
+
+ }
// display data