-
Notifications
You must be signed in to change notification settings - Fork 852
Move ModificationExecutors to new interface #11165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mchacki
merged 9 commits into
feature/AqlSubqueryExecutionBlockImplExecuteImplementation
from
feature/AqlSubqueryExecutionBlockImplExecuteImplementation-modificationExecutors
Feb 29, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
495b3bf
Move ModificationExecutors to new interface
f69ce81
Merge branch 'feature/AqlSubqueryExecutionBlockImplExecuteImplementat…
a4f4897
Merge branch 'feature/AqlSubqueryExecutionBlockImplExecuteImplementat…
80109a8
merge origin into feature branch
hkernbach f007de1
added inputRange method to inputMatrix class, added switch between
hkernbach 1679bfa
forgot to enable allrows modification executor in fastForwardType
hkernbach 853a281
removed obsolete comment
hkernbach a510a2e
removed obsolete comment
hkernbach 0672bd6
Merge branch 'feature/AqlSubqueryExecutionBlockImplExecuteImplementat…
mchacki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,37 +101,34 @@ ModificationExecutor<FetcherType, ModifierType>::ModificationExecutor(Fetcher& f | |
// Fetches as many rows as possible from upstream using the fetcher's fetchRow | ||
// method and accumulates results through the modifier | ||
template <typename FetcherType, typename ModifierType> | ||
std::pair<ExecutionState, typename ModificationExecutor<FetcherType, ModifierType>::Stats> | ||
ModificationExecutor<FetcherType, ModifierType>::doCollect(size_t maxOutputs) { | ||
auto ModificationExecutor<FetcherType, ModifierType>::doCollect(AqlItemBlockInputRange& input, | ||
size_t maxOutputs) | ||
-> void { | ||
// for fetchRow | ||
InputAqlItemRow row{CreateInvalidInputRowHint{}}; | ||
ExecutionState state = ExecutionState::HASMORE; | ||
|
||
// Maximum number of rows we can put into output | ||
// So we only ever produce this many here | ||
// TODO: If we SKIP_IGNORE, then we'd be able to output more; | ||
// this would require some counting to happen in the modifier | ||
while (_modifier.nrOfOperations() < maxOutputs && state != ExecutionState::DONE) { | ||
std::tie(state, row) = _fetcher.fetchRow(maxOutputs); | ||
if (state == ExecutionState::WAITING) { | ||
return {ExecutionState::WAITING, ModificationStats{}}; | ||
} | ||
if (row.isInitialized()) { | ||
// Make sure we have a valid row | ||
TRI_ASSERT(row.isInitialized()); | ||
_modifier.accumulate(row); | ||
} | ||
while (_modifier.nrOfOperations() < maxOutputs && input.hasDataRow()) { | ||
auto [state, row] = input.nextDataRow(); | ||
|
||
// Make sure we have a valid row | ||
TRI_ASSERT(row.isInitialized()); | ||
_modifier.accumulate(row); | ||
} | ||
TRI_ASSERT(state == ExecutionState::DONE || state == ExecutionState::HASMORE); | ||
return {state, ModificationStats{}}; | ||
} | ||
|
||
// Outputs accumulated results, and counts the statistics | ||
template <typename FetcherType, typename ModifierType> | ||
void ModificationExecutor<FetcherType, ModifierType>::doOutput(OutputAqlItemRow& output, | ||
Stats& stats) { | ||
typename ModifierType::OutputIterator modifierOutputIterator(_modifier); | ||
// We only accumulated as many items as we can output, so this | ||
// should be correct | ||
for (auto const& modifierOutput : modifierOutputIterator) { | ||
TRI_ASSERT(!output.isFull()); | ||
bool written = false; | ||
switch (modifierOutput.getType()) { | ||
case ModifierOutput::Type::ReturnIfRequired: | ||
|
@@ -157,53 +154,81 @@ void ModificationExecutor<FetcherType, ModifierType>::doOutput(OutputAqlItemRow& | |
break; | ||
} | ||
} | ||
|
||
if (_infos._doCount) { | ||
stats.addWritesExecuted(_modifier.nrOfWritesExecuted()); | ||
stats.addWritesIgnored(_modifier.nrOfWritesIgnored()); | ||
} | ||
} | ||
|
||
template <typename FetcherType, typename ModifierType> | ||
std::pair<ExecutionState, typename ModificationExecutor<FetcherType, ModifierType>::Stats> | ||
ModificationExecutor<FetcherType, ModifierType>::produceRows(OutputAqlItemRow& output) { | ||
TRI_ASSERT(false); | ||
|
||
return {ExecutionState::DONE, ModificationStats{}}; | ||
} | ||
|
||
template <typename FetcherType, typename ModifierType> | ||
[[nodiscard]] auto ModificationExecutor<FetcherType, ModifierType>::produceRows( | ||
typename FetcherType::DataRange& input, OutputAqlItemRow& output) | ||
-> std::tuple<ExecutorState, ModificationStats, AqlCall> { | ||
TRI_ASSERT(_infos._trx); | ||
|
||
ModificationExecutor::Stats stats; | ||
auto stats = ModificationStats{}; | ||
|
||
const size_t maxOutputs = std::min(output.numRowsLeft(), _modifier.getBatchSize()); | ||
_modifier.reset(); | ||
|
||
// if we returned "WAITING" the last time we still have | ||
// documents in the accumulator that we have not submitted | ||
// yet | ||
if (_lastState != ExecutionState::WAITING) { | ||
_modifier.reset(); | ||
ExecutorState upstreamState = ExecutorState::HASMORE; | ||
// only produce at most output.numRowsLeft() many results | ||
if constexpr (std::is_same_v<typename FetcherType::DataRange, AqlItemBlockInputMatrix>) { | ||
auto range = input.getNextInputRange(); | ||
doCollect(range, output.numRowsLeft()); | ||
upstreamState = range.upstreamState(); | ||
} else { | ||
doCollect(input, output.numRowsLeft()); | ||
upstreamState = input.upstreamState(); | ||
} | ||
|
||
TRI_IF_FAILURE("ModificationBlock::getSome") { | ||
THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG); | ||
} | ||
if (_modifier.nrOfOperations() > 0) { | ||
_modifier.transact(); | ||
|
||
std::tie(_lastState, stats) = doCollect(maxOutputs); | ||
if (_infos._doCount) { | ||
stats.addWritesExecuted(_modifier.nrOfWritesExecuted()); | ||
stats.addWritesIgnored(_modifier.nrOfWritesIgnored()); | ||
} | ||
|
||
if (_lastState == ExecutionState::WAITING) { | ||
return {ExecutionState::WAITING, std::move(stats)}; | ||
doOutput(output, stats); | ||
} | ||
|
||
TRI_ASSERT(_lastState == ExecutionState::DONE || _lastState == ExecutionState::HASMORE); | ||
return {upstreamState, stats, AqlCall{}}; | ||
} | ||
|
||
_modifier.transact(); | ||
template <typename FetcherType, typename ModifierType> | ||
[[nodiscard]] auto ModificationExecutor<FetcherType, ModifierType>::skipRowsRange( | ||
typename FetcherType::DataRange& input, AqlCall& call) | ||
-> std::tuple<ExecutorState, Stats, size_t, AqlCall> { | ||
auto stats = ModificationStats{}; | ||
_modifier.reset(); | ||
|
||
ExecutorState upstreamState = ExecutorState::HASMORE; | ||
// only produce at most output.numRowsLeft() many results | ||
if constexpr (std::is_same_v<typename FetcherType::DataRange, AqlItemBlockInputMatrix>) { | ||
auto range = input.getNextInputRange(); | ||
doCollect(range, call.getOffset()); | ||
upstreamState = range.upstreamState(); | ||
} else { | ||
doCollect(input, call.getOffset()); | ||
upstreamState = input.upstreamState(); | ||
} | ||
|
||
if (_modifier.nrOfOperations() > 0) { | ||
_modifier.transact(); | ||
|
||
// If the query is silent, there is no way to relate | ||
// the results slice contents and the submitted documents | ||
// If the query is *not* silent, we should get one result | ||
// for every document. | ||
// Yes. Really. | ||
TRI_ASSERT(_infos._options.silent || _modifier.nrOfDocuments() == _modifier.nrOfResults()); | ||
if (_infos._doCount) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is that not included in doOutput anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need it in the skip as well. |
||
stats.addWritesExecuted(_modifier.nrOfWritesExecuted()); | ||
stats.addWritesIgnored(_modifier.nrOfWritesIgnored()); | ||
} | ||
|
||
doOutput(output, stats); | ||
call.didSkip(_modifier.nrOfOperations()); | ||
} | ||
|
||
return {_lastState, std::move(stats)}; | ||
return {upstreamState, stats, _modifier.nrOfOperations(), AqlCall{}}; | ||
} | ||
|
||
using NoPassthroughSingleRowFetcher = SingleRowFetcher<BlockPassthrough::Disable>; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that not included in doOutput anymore?