diff --git a/arangod/Aql/UnsortedGatherExecutor.cpp b/arangod/Aql/UnsortedGatherExecutor.cpp index 9fff8e48b8..5f9d61ff9b 100644 --- a/arangod/Aql/UnsortedGatherExecutor.cpp +++ b/arangod/Aql/UnsortedGatherExecutor.cpp @@ -73,12 +73,9 @@ std::pair UnsortedGatherExecutor::produceRows(OutputAql ExecutionState state; InputAqlItemRow inputRow = InputAqlItemRow{CreateInvalidInputRowHint{}}; - bool more = false; - bool waiting = false; - - size_t i = _currentDependency; - for (size_t x = 0; x < _numberDependencies; ++x) { - i = (_currentDependency + x) % _numberDependencies; + size_t x; + for (x = 0; x < _numberDependencies; ++x) { + size_t i = (_currentDependency + x) % _numberDependencies; if (_upstream[i] == ExecutionState::DONE) { continue; @@ -98,23 +95,25 @@ std::pair UnsortedGatherExecutor::produceRows(OutputAql } _upstream[i] = state; - if (state == ExecutionState::HASMORE) { - more = true; - } else if (state == ExecutionState::WAITING) { - waiting = true; - } if (output.isFull()) { break; } } - _currentDependency = i; + _currentDependency = x; NoStats stats; - if (more) { - return {ExecutionState::HASMORE, stats}; - } else if (waiting) { + size_t numWaiting = 0; + for (x = 0; x < _numberDependencies; ++x) { + if (_upstream[x] == ExecutionState::HASMORE) { + return {ExecutionState::HASMORE, stats}; + } else if (_upstream[x] == ExecutionState::WAITING) { + numWaiting++; + } + } + if (numWaiting > 0) { return {ExecutionState::WAITING, stats}; } + TRI_ASSERT(std::all_of(_upstream.begin(), _upstream.end(), [](auto const& s) { return s == ExecutionState::DONE; } )); return {ExecutionState::DONE, stats}; } diff --git a/arangod/Aql/UnsortedGatherExecutor.h b/arangod/Aql/UnsortedGatherExecutor.h index 70f596f5e3..4a79e9a9f1 100644 --- a/arangod/Aql/UnsortedGatherExecutor.h +++ b/arangod/Aql/UnsortedGatherExecutor.h @@ -27,6 +27,7 @@ #include "Aql/ExecutionState.h" #include "Aql/ExecutorInfos.h" #include "Aql/InputAqlItemRow.h" +#include "Containers/SmallVector.h" namespace arangodb { @@ -76,9 +77,6 @@ class UnsortedGatherExecutor { */ std::pair produceRows(OutputAqlItemRow& output); -// std::pair expectedNumberOfRows(size_t atMost) const; -// std::tuple fetchBlockForPassthrough(size_t atMost); - std::tuple skipRows(size_t atMost); private: @@ -88,7 +86,8 @@ class UnsortedGatherExecutor { private: Fetcher& _fetcher; - std::vector _upstream; + ::arangodb::containers::SmallVector::allocator_type::arena_type _arena; + ::arangodb::containers::SmallVector _upstream{_arena}; // Total Number of dependencies size_t _numberDependencies;