From afd35ecf52051b1476546d2f2a124a0d97d9894d Mon Sep 17 00:00:00 2001 From: RobinTF <83676088+RobinTF@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:20:43 +0100 Subject: [PATCH] Merge directly without vector in Filter class (#1633) This commit affects the case when the input to a FILTER is lazy, but the result is fully materialized. Now the local vocabs of the lazy input blocks are directly merged into the local vocab of the result. Previously they were first stored in a vector, which had a higher RAM footprint for the case of many redundant and typically empty local vocabs in the input. --- src/engine/Filter.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/engine/Filter.cpp b/src/engine/Filter.cpp index db21cf7c43..1c8ff01404 100644 --- a/src/engine/Filter.cpp +++ b/src/engine/Filter.cpp @@ -71,19 +71,17 @@ ProtoResult Filter::computeResult(bool requestLaziness) { // single IdTable. size_t width = getSubtree().get()->getResultWidth(); IdTable result{width, getExecutionContext()->getAllocator()}; - std::vector localVocabs; + + LocalVocab resultLocalVocab{}; ad_utility::callFixedSize( - width, [this, &subRes, &result, &localVocabs]() { + width, [this, &subRes, &result, &resultLocalVocab]() { for (Result::IdTableVocabPair& pair : subRes->idTables()) { computeFilterImpl(result, pair.idTable_, pair.localVocab_, subRes->sortedBy()); - localVocabs.emplace_back(std::move(pair.localVocab_)); + resultLocalVocab.mergeWith(std::span{&pair.localVocab_, 1}); } }); - LocalVocab resultLocalVocab{}; - resultLocalVocab.mergeWith(localVocabs); - LOG(DEBUG) << "Filter result computation done." << endl; return {std::move(result), resultSortedOn(), std::move(resultLocalVocab)};