summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2021-09-21 08:28:36 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-21 08:53:20 +0000
commitc9df76ad4e2f9879cc5cb8ed371f36d2065acccc (patch)
tree42d211ff26ade213ed42350211c995748e9f12e9
parent3168343fc7ad220f86f908222f93332da4689872 (diff)
downloadmongo-c9df76ad4e2f9879cc5cb8ed371f36d2065acccc.tar.gz
SERVER-59465 Fix coverity issues in DocumentSourceDensify
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp28
-rw-r--r--src/mongo/db/pipeline/document_source_densify.h11
2 files changed, 20 insertions, 19 deletions
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index 53d72a8429c..34a8eafa214 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -85,13 +85,21 @@ RangeStatement RangeStatement::parse(RangeSpec spec) {
array[1].type() == mongo::Date);
uassert(5733410, "A bounding array of dates must specify a unit", unit);
return Bounds(std::pair<Date_t, Date_t>(array[0].date(), array[1].date()));
+ } else {
+ uasserted(5946800, "Explicit bounds must be numeric or dates");
}
+ MONGO_UNREACHABLE_TASSERT(5946801);
}
case mongo::String: {
if (bounds.str() == kValFull)
return Bounds(Full());
else if (bounds.str() == kValPartition)
return Bounds(Partition());
+ else
+ uasserted(5946802,
+ str::stream() << "Bounds string must either be '" << kValFull
+ << "' or '" << kValPartition << "'");
+ MONGO_UNREACHABLE_TASSERT(5946803);
}
default:
uasserted(5733404,
@@ -510,13 +518,13 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::finishDensifyingPar
_densifyState = DensifyState::kDensifyDone;
return DocumentSource::GetNextResult::makeEOF();
}
- return stdx::visit(visit_helper::Overloaded{[&](Full full) {
+ return stdx::visit(visit_helper::Overloaded{[&](Full) {
// Densify between partitions's last seen value
// and global max.
return finishDensifyingPartitionedInputHelper(
stdx::get<Value>(*_globalMax));
},
- [&](Partition partition) {
+ [&](Partition) {
// Partition bounds don't do any extra work
// after EOF;
MONGO_UNREACHABLE;
@@ -541,7 +549,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::handleSourceExhaust
_eof = true;
return stdx::visit(
visit_helper::Overloaded{
- [&](RangeStatement::Full full) {
+ [&](RangeStatement::Full) {
if (_partitionExpr) {
return finishDensifyingPartitionedInput();
} else {
@@ -549,7 +557,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::handleSourceExhaust
return DocumentSource::GetNextResult::makeEOF();
}
},
- [&](RangeStatement::Partition part) {
+ [&](RangeStatement::Partition) {
// We have already densified up to the last document in each partition.
_densifyState = DensifyState::kDensifyDone;
return DocumentSource::GetNextResult::makeEOF();
@@ -735,13 +743,13 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() {
return stdx::visit(
visit_helper::Overloaded{
- [&](Full full) {
+ [&](Full) {
_current = val;
_globalMin = val;
_densifyState = DensifyState::kNeedGen;
return nextDoc;
},
- [&](Partition partition) {
+ [&](Partition) {
tassert(5734400,
"Partition state must be initialized for partition bounds",
_partitionExpr);
@@ -777,7 +785,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() {
return stdx::visit(
visit_helper::Overloaded{
- [&](Full full) {
+ [&](Full) {
if (_partitionExpr) {
// Keep track of '_globalMax' for later. The latest document from the
// source is always the max.
@@ -800,7 +808,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() {
}
return handleNeedGen(currentDoc, val);
},
- [&](Partition partition) {
+ [&](Partition) {
// If we haven't seen this partition before, add it to the table then
// return.
auto partitionVal = getDensifyPartition(currentDoc);
@@ -845,7 +853,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() {
return stdx::visit(
visit_helper::Overloaded{
- [&](Full full) {
+ [&](Full) {
if (_docGenerator->done()) {
_docGenerator = boost::none;
if (_eof && _partitionExpr) {
@@ -862,7 +870,7 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::doGetNext() {
}
return GetNextResult(std::move(generatedDoc));
},
- [&](Partition partition) {
+ [&](Partition) {
if (_docGenerator->done()) {
_docGenerator = boost::none;
_densifyState = DensifyState::kNeedGen;
diff --git a/src/mongo/db/pipeline/document_source_densify.h b/src/mongo/db/pipeline/document_source_densify.h
index 9ef885eb848..a00cd33f478 100644
--- a/src/mongo/db/pipeline/document_source_densify.h
+++ b/src/mongo/db/pipeline/document_source_densify.h
@@ -79,8 +79,8 @@ public:
spec[kArgStep] = _step;
spec[kArgBounds] = stdx::visit(
visit_helper::Overloaded{
- [&](Full full) { return Value(kValFull); },
- [&](Partition partition) { return Value(kValPartition); },
+ [&](Full) { return Value(kValFull); },
+ [&](Partition) { return Value(kValPartition); },
[&](std::pair<Date_t, Date_t> dates) {
return Value(std::vector<Value>({Value(dates.first), Value(dates.second)}));
},
@@ -367,14 +367,7 @@ private:
kDensifyDone
};
- enum class TypeOfDensify {
- kFull,
- kExplicitRange,
- kPartition,
- };
-
DensifyState _densifyState = DensifyState::kUninitializedOrBelowRange;
- TypeOfDensify _densifyType;
FieldPath _field;
std::list<FieldPath> _partitions;
RangeStatement _range;