summaryrefslogtreecommitdiff
path: root/tools/stat.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-11-03 18:28:12 -0400
committerEliot Horowitz <eliot@10gen.com>2010-11-03 18:57:19 -0400
commitb741e68528ecfc6bb06f82355db1d9d8d0c4c43a (patch)
tree27316f24aae281417b0d2f69c20f9ea49b0da732 /tools/stat.cpp
parent2dce387d96b7edf2e920bf235fa5f6ec5422c063 (diff)
downloadmongo-b741e68528ecfc6bb06f82355db1d9d8d0c4c43a.tar.gz
better printing for mongos + shards SERVER-2038
Diffstat (limited to 'tools/stat.cpp')
-rw-r--r--tools/stat.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp
index 780aef19798..fd5b9d18319 100644
--- a/tools/stat.cpp
+++ b/tools/stat.cpp
@@ -300,13 +300,20 @@ namespace mongo {
cout << endl;
}
- static void printData( const BSONObj& o ){
- BSONObjIterator i(o);
+ static void printData( const BSONObj& o , const BSONObj& headers ){
+
+ BSONObjIterator i(headers);
while ( i.more() ){
- BSONObj x = i.next().Obj();
- int w = x["width"].numberInt();
+ BSONElement e = i.next();
+ BSONObj h = e.Obj();
+ int w = h["width"].numberInt();
- BSONElement data = x["data"];
+ BSONElement data;
+ {
+ BSONElement temp = o[e.fieldName()];
+ if ( temp.isABSONObj() )
+ data = temp.Obj()["data"];
+ }
if ( data.type() == String )
cout << setw(w) << data.String();
@@ -314,6 +321,10 @@ namespace mongo {
cout << setw(w) << setprecision(3) << data.number();
else if ( data.type() == NumberInt )
cout << setw(w) << data.numberInt();
+ else if ( data.eoo() )
+ cout << setw(w) << "";
+ else
+ cout << setw(w) << "???";
cout << ' ';
}
@@ -351,7 +362,7 @@ namespace mongo {
printHeaders( out );
}
- printData( out );
+ printData( out , out );
}
catch ( AssertionException& e ){
@@ -557,7 +568,7 @@ namespace mongo {
if ( rows[i].data.nFields() > biggest.nFields() )
biggest = rows[i].data;
}
-
+
// display data
@@ -577,7 +588,7 @@ namespace mongo {
else if ( rows[i].data.isEmpty() )
cout << "no data" << endl;
else
- printData( rows[i].data );
+ printData( rows[i].data , biggest );
}
}