8000 AQL Subquery: MultiDependencyRowFetcher (#10101) · arangodb/arangodb@4e86de0 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 4e86de0

Browse files
goedderzmchacki
authored andcommitted
AQL Subquery: MultiDependencyRowFetcher (#10101)
Add ShadowRow support for MultiDependencyRowFetcher
1 parent 6528c59 commit 4e86de0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1582
-250
lines changed

arangod/Aql/CollectNode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "Aql/ExecutionPlan.h"
3131
#include "Aql/HashedCollectExecutor.h"
3232
#include "Aql/Query.h"
33+
#include "Aql/RegisterPlan.h"
3334
#include "Aql/SingleRowFetcher.h"
3435
#include "Aql/SortedCollectExecutor.h"
3536
#include "Aql/VariableGenerator.h"

arangod/Aql/DependencyProxy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ class DependencyProxy {
8787
size_t dependency, size_t atMost = ExecutionBlock::DefaultBatchSize());
8888

8989
// See comment on fetchBlockForDependency().
90-
std::pair<ExecutionState, size_t> skipSomeForDependency(size_t dependency, size_t atMost);
90+
TEST_VIRTUAL std::pair<ExecutionState, size_t> skipSomeForDependency(size_t dependency,
91+
size_t atMost);
9192

9293
// TODO enable_if<allowBlockPassthrough>
9394
std::pair<ExecutionState, SharedAqlItemBlockPtr> fetchBlockForPassthrough(size_t atMost);
9495

95-
std::pair<ExecutionState, size_t> skipSome(size_t atMost);
96+
TEST_VIRTUAL std::pair<ExecutionState, size_t> skipSome(size_t atMost);
9697

9798
TEST_VIRTUAL RegisterId getNrInputRegisters() const;
9899

arangod/Aql/DistributeConsumerNode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "Aql/ClusterNodes.h"
2626
#include "Aql/ExecutionBlock.h"
2727
#include "Aql/IdExecutor.h"
28+
#include "Aql/RegisterPlan.h"
2829
#include "Aql/SingleRowFetcher.h"
2930
#include "Basics/VelocyPackHelper.h"
3031

arangod/Aql/DistributeExecutor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
#include "Aql/ClusterNodes.h"
2626
#include "Aql/Collection.h"
2727
#include "Aql/ExecutionEngine.h"
28-
#include "Aql/ExecutionNode.h"
28+
#include "Aql/RegisterPlan.h"
2929
#include "Basics/StaticStrings.h"
30-
#include "VocBase/LogicalCollection.h"
3130

3231
#include <velocypack/Collection.h>
3332
#include <velocypack/velocypack-aliases.h>

arangod/Aql/ExecutionBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#include "Basics/system-functions.h"
3636
#include "Logger/LogMacros.h"
3737
#include "Logger/Logger.h"
38-
#include "Transaction/Methods.h"
3938
#include "Transaction/Context.h"
39+
#include "Transaction/Methods.h"
4040

4141
#include <velocypack/Builder.h>
4242
#include <velocypack/Dumper.h>

arangod/Aql/ExecutionBlockImpl.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,29 @@ static SkipVariants constexpr skipType() {
337337
} // namespace arangodb
338338

339339
template <class Executor>
340-
std::pair<ExecutionState, size_t> ExecutionBlockImpl<Executor>::skipSome(size_t atMost) {
340+
std::pair<ExecutionState, size_t> ExecutionBlockImpl<Executor>::skipSome(size_t const atMost) {
341341
traceSkipSomeBegin(atMost);
342+
auto state = ExecutionState::HASMORE;
343+
344+
while (state == ExecutionState::HASMORE && _skipped < atMost) {
345+
auto res = skipSomeOnceWithoutTrace(atMost - _skipped);
346+
TRI_ASSERT(state != ExecutionState::WAITING || res.second == 0);
347+
state = res.first;
348+
_skipped += res.second;
349+
TRI_ASSERT(_skipped <= atMost);
350+
}
351+
352+
size_t skipped = 0;
353+
if (state != ExecutionState::WAITING) {
354+
std::swap(skipped, _skipped);
355+
}
356+
357+
TRI_ASSERT(skipped <= atMost);
358+
return traceSkipSomeEnd(state, skipped);
359+
}
342360

361+
template <class Executor>
362+
std::pair<ExecutionState, size_t> ExecutionBlockImpl<Executor>::skipSomeOnceWithoutTrace(size_t atMost) {
343363
constexpr SkipVariants customSkipType = skipType<Executor>();
344364

345365
if (customSkipType == SkipVariants::GET_SOME) {
@@ -352,7 +372,7 @@ std::pair<ExecutionState, size_t> ExecutionBlockImpl<Executor>::skipSome(size_t
352372
}
353373
TRI_ASSERT(skipped <= atMost);
354374

355-
return traceSkipSomeEnd({res.first, skipped});
375+
return {res.first, skipped};
356376
}
357377

358378
ExecutionState state;
@@ -363,9 +383,10 @@ std::pair<ExecutionState, size_t> ExecutionBlockImpl<Executor>::skipSome(size_t
363383
_engine->_stats += stats;
364384
TRI_ASSERT(skipped <= atMost);
365385

366-
return traceSkipSomeEnd(state, skipped);
386+
return {state, skipped};
367387
}
368388

389+
369390
template <bool customInit>
370391
struct InitializeCursor {};
371392

@@ -399,6 +420,9 @@ std::pair<ExecutionState, Result> ExecutionBlockImpl<Executor>::initializeCursor
399420
_rowFetcher.~Fetcher();
400421
new (&_rowFetcher) Fetcher(_dependencyProxy);
401422

423+
TRI_ASSERT(_skipped == 0);
424+
_skipped = 0;
425+
402426
constexpr bool customInit = hasInitializeCursor<Executor>::value;
403427
// IndexExecutor and EnumerateCollectionExecutor have initializeCursor
404428
// implemented, so assert this implementation is used.
@@ -445,6 +469,9 @@ std::pair<ExecutionState, Result> ExecutionBlockImpl<IdExecutor<BlockPassthrough
445469
_rowFetcher.~Fetcher();
446470
new (&_rowFetcher) Fetcher(_dependencyProxy);
447471

472+
TRI_ASSERT(_skipped == 0);
473+
_skipped = 0;
474+
448475
SharedAqlItemBlockPtr block =
449476
input.cloneToBlock(_engine->itemBlockManager(), *(infos().registersToKeep()),
450477
infos().numberOfOutputRegisters());

arangod/Aql/ExecutionBlockImpl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ class ExecutionBlockImpl final : public ExecutionBlock {
180180
*/
181181
std::pair<ExecutionState, SharedAqlItemBlockPtr> getSomeWithoutTrace(size_t atMost);
182182

183+
/**
184+
* @brief Inner getSome() part, without the tracing calls.
185+
*/
186+
std::pair<ExecutionState, size_t> skipSomeOnceWithoutTrace(size_t atMost);
187+
183188
/**
184189
* @brief Allocates a new AqlItemBlock and returns it, with the specified
185190
* number of rows (nrItems) and columns (nrRegs).
@@ -230,6 +235,8 @@ class ExecutionBlockImpl final : public ExecutionBlock {
230235
std::unique_ptr<OutputAqlItemRow> _outputItemRow;
231236

232237
Query const& _query;
238+
239+
size_t _skipped{};
233240
};
234241

235242
} // namespace aql

arangod/Aql/ExecutionNode.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "Aql/NodeFinder.h"
5151
#include "Aql/Query.h"
5252
#include "Aql/Range.h"
53+
#include "Aql/RegisterPlan.h"
5354
#include "Aql/ReturnExecutor.h"
5455
#include "Aql/ShortestPathNode.h"
5556
#include "Aql/SortCondition.h"

arangod/Aql/HashedCollectExecutor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "Aql/ExecutorInfos.h"
3232
#include "Aql/InputAqlItemRow.h"
3333
#include "Aql/OutputAqlItemRow.h"
34+
#include "Aql/RegisterPlan.h"
3435
#include "Aql/SingleRowFetcher.h"
3536

3637
#include <utility>

arangod/Aql/IndexNode.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
#include "Aql/ExecutionBlockImpl.h"
3030
#include "Aql/ExecutionNode.h"
3131
#include "Aql/ExecutionPlan.h"
32+
#include "Aql/Expression.h"
3233
#include "Aql/IndexExecutor.h"
3334
#include "Aql/Query.h"
35+
#include "Aql/RegisterPlan.h"
36+
#include "Aql/SingleRowFetcher.h"
3437
#include "Basics/AttributeNameParser.h"
3538
#include "Basics/StringUtils.h"
3639
#include "Basics/VelocyPackHelper.h"
3740
#include "Indexes/Index.h"
3841
#include "StorageEngine/EngineSelectorFeature.h"
3942
#include "StorageEngine/StorageEngine.h"
4043
#include "Transaction/Methods.h"
41-
#include "Aql/Expression.h"
42-
#include "Aql/SingleRowFetcher.h"
4344

4445
#include <velocypack/Iterator.h>
4546
#include <velocypack/velocypack-aliases.h>

0 commit comments

Comments
 (0)
0