1
0
Fork 0

Removed debug output and activated the first tests for subquery execution

This commit is contained in:
Michael Hackstein 2019-10-09 13:10:37 +02:00
parent a4cd7b0ee6
commit 6268679d50
2 changed files with 9 additions and 28 deletions

View File

@ -168,7 +168,6 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
TRI_ASSERT(newBlock->size() > 0);
TRI_ASSERT(newBlock->size() <= atMost);
_outputItemRow = createOutputRow(newBlock);
LOG_DEVEL << typeid(_executor).name() << "outreg on block: " << newBlock->getNrRegs();
}
ExecutionState state = ExecutionState::HASMORE;
@ -178,14 +177,11 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
// The loop has to be entered at least once!
TRI_ASSERT(!_outputItemRow->isFull());
while (!_outputItemRow->isFull()) {
while (!_outputItemRow->isFull() && _state != InternalState::DONE) {
// Assert that write-head is always pointing to a free row
TRI_ASSERT(!_outputItemRow->produced());
switch (_state) {
case InternalState::FETCH_DATA: {
LOG_DEVEL << typeid(_executor).name() << ": fetching data";
LOG_DEVEL << typeid(_executor).name()
<< "outreg before produce: " << _outputItemRow->getNrRegisters();
std::tie(state, executorStats) = _executor.produceRows(*_outputItemRow);
// Count global but executor-specific statistics, like number of
// filtered rows.
@ -204,7 +200,6 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
break;
}
case InternalState::FETCH_SHADOWROWS: {
LOG_DEVEL << typeid(_executor).name() << ": fetching shadow rows";
ShadowAqlItemRow shadowRow{CreateInvalidShadowRowHint{}};
// TODO: Add lazy evaluation in case of LIMIT "lying" on done
std::tie(state, shadowRow) = _rowFetcher.fetchShadowRow();
@ -217,7 +212,6 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
_state = InternalState::DONE;
}
if (shadowRow.isInitialized()) {
LOG_DEVEL << typeid(_executor).name() << ": copy shadow rows";
_outputItemRow->copyRow(shadowRow);
TRI_ASSERT(_outputItemRow->produced());
_outputItemRow->advanceRow();
@ -231,19 +225,11 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
break;
}
case InternalState::DONE: {
TRI_ASSERT(state == ExecutionState::DONE);
LOG_DEVEL << typeid(_executor).name() << ": DONE";
auto outputBlock = _outputItemRow->stealBlock();
// This is not strictly necessary here, as we shouldn't be called
// again after DONE.
_outputItemRow.reset();
return {ExecutionState::DONE, std::move(outputBlock)};
break;
TRI_ASSERT(false); // Invalid state
}
}
}
TRI_ASSERT(_state != InternalState::DONE);
// When we're passing blocks through we have no control over the size of the
// output block.
// Plus, the ConstrainedSortExecutor will report an expectedNumberOfRows
@ -266,9 +252,11 @@ std::pair<ExecutionState, SharedAqlItemBlockPtr> ExecutionBlockImpl<Executor>::g
auto outputBlock = _outputItemRow->stealBlock();
// we guarantee that we do return a valid pointer in the HASMORE case.
TRI_ASSERT(outputBlock != nullptr);
// But we might return a nullptr in DONE case
TRI_ASSERT(outputBlock != nullptr || _state == InternalState::DONE);
_outputItemRow.reset();
return {ExecutionState::HASMORE, std::move(outputBlock)};
return {(_state == InternalState::DONE ? ExecutionState::DONE : ExecutionState::HASMORE),
std::move(outputBlock)};
}
template <class Executor>
@ -785,7 +773,6 @@ SharedAqlItemBlockPtr ExecutionBlockImpl<Executor>::requestBlock(size_t nrItems,
/// @brief reset all internal states after processing a shadow row.
template <class Executor>
void ExecutionBlockImpl<Executor>::resetAfterShadowRow() {
LOG_DEVEL << "Reset after shadowRow";
// cppcheck-suppress unreadVariable
constexpr bool customInit = hasInitializeCursor<decltype(_executor)>::value;
InitializeCursor<customInit>::init(_executor, _rowFetcher, _infos);

View File

@ -197,24 +197,18 @@ class SpliceSubqueryNodeOptimizerRuleTest : public ::testing::Test {
// First test original Query (rule-disabled)
{
LOG_DEVEL << "Disabled rule";
auto queryResult =
arangodb::tests::executeQuery(server.getSystemDatabase(), query,
bindParameters, disableRuleOptions());
compareQueryResultToSlice(queryResult, false, expected);
LOG_DEVEL << "...";
LOG_DEVEL << "...";
}
// Second test optimized Query (rule-enabled)
{
LOG_DEVEL << "Enabled rule";
auto queryResult =
arangodb::tests::executeQuery(server.getSystemDatabase(), query,
bindParameters, enableRuleOptions());
compareQueryResultToSlice(queryResult, true, expected);
LOG_DEVEL << "...";
LOG_DEVEL << "...";
}
}
@ -242,7 +236,7 @@ TEST_F(SpliceSubqueryNodeOptimizerRuleTest, splice_subquery_single_input) {
verifyQueryResult(query, expected->slice());
}
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, DISABLED_splice_subquery_plan) {
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, splice_subquery_plan) {
auto query = R"aql(FOR d IN 1..2
LET first =
(FOR e IN 1..2 FILTER d == e RETURN e)
@ -253,7 +247,7 @@ TEST_F(SpliceSubqueryNodeOptimizerRuleTest, DISABLED_splice_subquery_plan) {
verifyQueryResult(query, expected->slice());
}
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, DISABLED_splice_subquery_in_subquery_plan) {
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, splice_subquery_in_subquery_plan) {
auto query = R"aql(FOR d IN 1..2
LET first = (FOR e IN 1..2
LET second = (FOR f IN 1..2 RETURN f)
@ -268,7 +262,7 @@ TEST_F(SpliceSubqueryNodeOptimizerRuleTest, DISABLED_splice_subquery_in_subquery
verifyQueryResult(query, expected->slice());
}
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, DISABLED_splice_subquery_after_subquery_plan) {
TEST_F(SpliceSubqueryNodeOptimizerRuleTest, splice_subquery_after_subquery_plan) {
auto query = R"aql(FOR d IN 1..2
LET first = (FOR e IN 1..2 FILTER d == e RETURN e)
LET second = (FOR e IN 1..2 FILTER d != e RETURN e)