summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Cox <eric.cox@mongodb.com>2022-06-13 17:29:05 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-16 19:41:29 +0000
commit342552401af6b49d37bdc2a507c5524642bb4e95 (patch)
tree8c0ae8a235c20c7ec7b78bd1056bd82903fa2a04 /src
parent1bf1161e5db69fcee1aaa135b18ae6d9e10e94e5 (diff)
downloadmongo-342552401af6b49d37bdc2a507c5524642bb4e95.tar.gz
SERVER-66989 Make HashAgg record store key owned
(cherry picked from commit e399422548621ca737903284e8b435c804bb8254)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/exec/sbe/stages/hash_agg.cpp4
-rw-r--r--src/mongo/db/exec/sbe/stages/hash_agg.h5
-rw-r--r--src/mongo/db/exec/sbe/util/spilling.cpp3
3 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/db/exec/sbe/stages/hash_agg.cpp b/src/mongo/db/exec/sbe/stages/hash_agg.cpp
index 73a2375d417..bdb1f7388a6 100644
--- a/src/mongo/db/exec/sbe/stages/hash_agg.cpp
+++ b/src/mongo/db/exec/sbe/stages/hash_agg.cpp
@@ -501,9 +501,9 @@ PlanState HashAggStage::getNext() {
KeyString::TypeBits::fromBuffer(KeyString::Version::kLatestVersion, &valReader);
_aggValueRecordStore = val;
- BufBuilder buf;
+ _aggKeyRSBuffer.reset();
_aggKeyRecordStore = value::MaterializedRow::deserializeFromKeyString(
- decodeKeyString(nextRecord->id, typeBits), &buf);
+ decodeKeyString(nextRecord->id, typeBits), &_aggKeyRSBuffer);
return trackPlanState(PlanState::ADVANCED);
} else {
_rsCursor.reset();
diff --git a/src/mongo/db/exec/sbe/stages/hash_agg.h b/src/mongo/db/exec/sbe/stages/hash_agg.h
index 8c117e8717d..19fbca9d1c7 100644
--- a/src/mongo/db/exec/sbe/stages/hash_agg.h
+++ b/src/mongo/db/exec/sbe/stages/hash_agg.h
@@ -184,6 +184,11 @@ private:
std::vector<std::unique_ptr<value::MaterializedSingleRowAccessor>> _outRecordStoreKeyAccessors;
std::vector<std::unique_ptr<value::MaterializedSingleRowAccessor>> _outRecordStoreAggAccessors;
+ // This buffer stores values for the spilled '_aggKeyRecordStore' that's loaded into memory from
+ // the '_recordStore'. Values in the '_aggKeyRecordStore' row are pointers that point to data in
+ // this buffer.
+ BufBuilder _aggKeyRSBuffer;
+
std::vector<value::SlotAccessor*> _seekKeysAccessors;
value::MaterializedRow _seekKeys;
diff --git a/src/mongo/db/exec/sbe/util/spilling.cpp b/src/mongo/db/exec/sbe/util/spilling.cpp
index 45931efec8b..c54f3bfe956 100644
--- a/src/mongo/db/exec/sbe/util/spilling.cpp
+++ b/src/mongo/db/exec/sbe/util/spilling.cpp
@@ -63,8 +63,7 @@ boost::optional<value::MaterializedRow> readFromRecordStore(OperationContext* op
RecordData record;
if (rs->findRecord(opCtx, rid, &record)) {
auto valueReader = BufReader(record.data(), record.size());
- auto val = value::MaterializedRow::deserializeForSorter(valueReader, {});
- return val;
+ return value::MaterializedRow::deserializeForSorter(valueReader, {});
}
return boost::none;
}