From 26509f8557d337130cc6e0228989f7cd374addef Mon Sep 17 00:00:00 2001 From: RobinTF <83676088+RobinTF@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:58:10 +0100 Subject: [PATCH] Minor code fixes --- src/engine/TransitivePathBase.cpp | 21 +++++++++++---------- src/engine/TransitivePathImpl.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/engine/TransitivePathBase.cpp b/src/engine/TransitivePathBase.cpp index 5e9f69d6ca..a833bfdfbd 100644 --- a/src/engine/TransitivePathBase.cpp +++ b/src/engine/TransitivePathBase.cpp @@ -96,6 +96,9 @@ Result::Generator TransitivePathBase::fillTableWithHullImpl( std::vector storedLocalVocabs; for (auto& [node, linkedNodes, localVocab, idTable, inputRow] : hull) { timer.cont(); + // As an optimization nodes without any linked nodes should not get yielded + // in the first place. + AD_CONTRACT_CHECK(!linkedNodes.empty()); if (!yieldOnce) { table.reserve(linkedNodes.size()); } @@ -116,16 +119,14 @@ Result::Generator TransitivePathBase::fillTableWithHullImpl( outputRow++; } - if (!table.empty()) { - if (yieldOnce) { - storedLocalVocabs.emplace_back(std::move(localVocab)); - } else { - timer.stop(); - runtimeInfo().addDetail("IdTable fill time", timer.msecs()); - co_yield {std::move(table).toDynamic(), std::move(localVocab)}; - table = IdTableStatic{getResultWidth(), allocator()}; - outputRow = 0; - } + if (yieldOnce) { + storedLocalVocabs.emplace_back(std::move(localVocab)); + } else { + timer.stop(); + runtimeInfo().addDetail("IdTable fill time", timer.msecs()); + co_yield {std::move(table).toDynamic(), std::move(localVocab)}; + table = IdTableStatic{getResultWidth(), allocator()}; + outputRow = 0; } timer.stop(); } diff --git a/src/engine/TransitivePathImpl.h b/src/engine/TransitivePathImpl.h index 6d690daffc..407b63a298 100644 --- a/src/engine/TransitivePathImpl.h +++ b/src/engine/TransitivePathImpl.h @@ -252,14 +252,14 @@ class TransitivePathImpl : public TransitivePathBase { mergedVocab.mergeWith(std::span{&edgesVocab, 1}); size_t currentRow = 0; for (Id startNode : tableColumn.column_) { - timer.cont(); Set connectedNodes = findConnectedNodes(edges, startNode, target); if (!connectedNodes.empty()) { - timer.stop(); runtimeInfo().addDetail("Hull time", timer.msecs()); + timer.stop(); co_yield NodeWithTargets{startNode, std::move(connectedNodes), mergedVocab.clone(), tableColumn.table_, currentRow}; + timer.cont(); } currentRow++; }