1
0
Fork 0

change algorithm a bit

This commit is contained in:
Simon Grätzer 2019-11-06 14:56:37 +01:00
parent ce539002e1
commit cebf0fbb1a
No known key found for this signature in database
GPG Key ID: E4736AA091116E5C
2 changed files with 17 additions and 19 deletions

View File

@ -73,12 +73,9 @@ std::pair<ExecutionState, NoStats> 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<ExecutionState, NoStats> 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};
}

View File

@ -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<ExecutionState, Stats> produceRows(OutputAqlItemRow& output);
// std::pair<ExecutionState, size_t> expectedNumberOfRows(size_t atMost) const;
// std::tuple<ExecutionState, Stats, SharedAqlItemBlockPtr> fetchBlockForPassthrough(size_t atMost);
std::tuple<ExecutionState, Stats, size_t> skipRows(size_t atMost);
private:
@ -88,7 +86,8 @@ class UnsortedGatherExecutor {
private:
Fetcher& _fetcher;
std::vector<ExecutionState> _upstream;
::arangodb::containers::SmallVector<ExecutionState>::allocator_type::arena_type _arena;
::arangodb::containers::SmallVector<ExecutionState> _upstream{_arena};
// Total Number of dependencies
size_t _numberDependencies;