diff options
| author | Timour Katchaounov <timour.katchaounov@mongodb.com> | 2022-10-20 05:37:28 +0000 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-20 06:10:35 +0000 |
| commit | 28450cf43e1c28c2bf6b75c9fdfec6ad96ad584b (patch) | |
| tree | 02c72f95452324e587c5d1c463d97e3a4b4fa3db /src/mongo/db/query/ce/array_histogram.cpp | |
| parent | 426956403eeb184097ea4e1933289fc64d590676 (diff) | |
| download | mongo-28450cf43e1c28c2bf6b75c9fdfec6ad96ad584b.tar.gz | |
SERVER-70514 Estimate number of arrays via type counter
Diffstat (limited to 'src/mongo/db/query/ce/array_histogram.cpp')
| -rw-r--r-- | src/mongo/db/query/ce/array_histogram.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/mongo/db/query/ce/array_histogram.cpp b/src/mongo/db/query/ce/array_histogram.cpp index 6050625846a..216bfa3fcc5 100644 --- a/src/mongo/db/query/ce/array_histogram.cpp +++ b/src/mongo/db/query/ce/array_histogram.cpp @@ -40,9 +40,11 @@ ArrayHistogram::ArrayHistogram(ScalarHistogram scalar, ScalarHistogram arrayUnique, ScalarHistogram arrayMin, ScalarHistogram arrayMax, - TypeCounts arrayTypeCounts) + TypeCounts arrayTypeCounts, + size_t emptyArrayCount) : _scalar(std::move(scalar)), _typeCounts(std::move(typeCounts)), + _emptyArrayCount(emptyArrayCount), _arrayUnique(std::move(arrayUnique)), _arrayMin(std::move(arrayMin)), _arrayMax(std::move(arrayMax)), @@ -55,6 +57,7 @@ ArrayHistogram::ArrayHistogram(ScalarHistogram scalar, ArrayHistogram::ArrayHistogram(ScalarHistogram scalar, TypeCounts typeCounts) : _scalar(std::move(scalar)), _typeCounts(std::move(typeCounts)), + _emptyArrayCount(0), _arrayUnique(boost::none), _arrayMin(boost::none), _arrayMax(boost::none), @@ -136,17 +139,4 @@ size_t ArrayHistogram::getArrayCount() const { return 0; } -size_t ArrayHistogram::getEmptyArrayCount() const { - if (isArray()) { - size_t nonEmptyArrayCount = _arrayMin->empty() ? 0 : _arrayMin->getCardinality(); - size_t totalArrCount = getArrayCount(); - uassert(6979502, - "The number of empty arrays is < the total number of arrays.", - totalArrCount >= nonEmptyArrayCount); - size_t emptyArrCount = totalArrCount - nonEmptyArrayCount; - return emptyArrCount; - } - return 0; -} - } // namespace mongo::ce |
