summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-02-22 15:42:13 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-02-26 12:58:59 -0500
commitfc8bf3751bef83ebe2b98f1e9496be3e8209b294 (patch)
tree7486785fef197004d04d7cee3549d961b8b4a208
parent62f4fd592c0004c18c7c1ecf20788436c6ead262 (diff)
downloadmongo-fc8bf3751bef83ebe2b98f1e9496be3e8209b294.tar.gz
SERVER-33127 Ensure that 'count' value is always returned as part of the `collStats` command
Also gets rid of some legacy fields which are no longer expected to be seen.
-rw-r--r--src/mongo/s/commands/commands_public.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index 4186bacfed0..bdbe57671c2 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -535,27 +535,23 @@ public:
return commandResponse.response;
}();
- BSONObjIterator j(res);
- // We don't know the order that we will encounter the count and size
- // So we save them until we've iterated through all the fields before
- // updating unscaledCollSize.
- long long shardObjCount;
- long long shardAvgObjSize;
- while (j.more()) {
- BSONElement e = j.next();
- if (str::equals(e.fieldName(), "ns") || str::equals(e.fieldName(), "ok") ||
- str::equals(e.fieldName(), "lastExtentSize") ||
+ // We don't know the order that we will encounter the count and size, so we save them
+ // until we've iterated through all the fields before updating unscaledCollSize
+ const auto shardObjCount = static_cast<long long>(res["count"].Number());
+ long long shardAvgObjSize = 0;
+
+ for (const auto& e : res) {
+ if (str::equals(e.fieldName(), "ns") || //
+ str::equals(e.fieldName(), "ok") || //
+ str::equals(e.fieldName(), "lastExtentSize") || //
str::equals(e.fieldName(), "paddingFactor")) {
continue;
- } else if (str::equals(e.fieldName(), "count") ||
- str::equals(e.fieldName(), "size") ||
- str::equals(e.fieldName(), "storageSize") ||
- str::equals(e.fieldName(), "numExtents") ||
+ } else if (str::equals(e.fieldName(), "count") || //
+ str::equals(e.fieldName(), "size") || //
+ str::equals(e.fieldName(), "storageSize") || //
+ str::equals(e.fieldName(), "numExtents") || //
str::equals(e.fieldName(), "totalIndexSize")) {
counts[e.fieldName()] += e.numberLong();
- if (str::equals(e.fieldName(), "count")) {
- shardObjCount = e.numberLong();
- }
} else if (str::equals(e.fieldName(), "avgObjSize")) {
shardAvgObjSize = e.numberLong();
} else if (str::equals(e.fieldName(), "indexSizes")) {
@@ -564,16 +560,6 @@ public:
BSONElement temp = k.next();
indexSizes[temp.fieldName()] += temp.numberLong();
}
- }
- // no longer used since 2.2
- else if (str::equals(e.fieldName(), "flags")) {
- if (!result.hasField(e.fieldName()))
- result.append(e);
- }
- // flags broken out in 2.4+
- else if (str::equals(e.fieldName(), "systemFlags")) {
- if (!result.hasField(e.fieldName()))
- result.append(e);
} else if (str::equals(e.fieldName(), "userFlags")) {
if (!result.hasField(e.fieldName()))
result.append(e);
@@ -585,8 +571,6 @@ public:
result.append(e);
} else if (str::equals(e.fieldName(), "indexDetails")) {
// skip this field in the rollup
- } else if (str::equals(e.fieldName(), "wiredTiger")) {
- // skip this field in the rollup
} else if (str::equals(e.fieldName(), "nindexes")) {
int myIndexes = e.numberInt();