From 801c957348f78e9daec4cda76b968509a4aca8a9 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 3 Jul 2019 16:15:15 +0200 Subject: [PATCH] add initializeCursor back to DistinctCollectExecutor (#9386) --- arangod/Aql/DistinctCollectExecutor.cpp | 21 +++++++++++++++------ arangod/Aql/DistinctCollectExecutor.h | 3 +++ arangod/Aql/ExecutionBlockImpl.cpp | 3 +++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/arangod/Aql/DistinctCollectExecutor.cpp b/arangod/Aql/DistinctCollectExecutor.cpp index 22eefcc548..8d40cebb51 100644 --- a/arangod/Aql/DistinctCollectExecutor.cpp +++ b/arangod/Aql/DistinctCollectExecutor.cpp @@ -64,12 +64,11 @@ DistinctCollectExecutor::DistinctCollectExecutor(Fetcher& fetcher, Infos& infos) AqlValueGroupEqual(_infos.getTransaction())) {} DistinctCollectExecutor::~DistinctCollectExecutor() { - // destroy all AqlValues captured - for (auto& it : _seen) { - for (auto& it2 : it) { - const_cast(&it2)->destroy(); - } - } + destroyValues(); +} + +void DistinctCollectExecutor::initializeCursor() { + destroyValues(); } std::pair DistinctCollectExecutor::produceRows(OutputAqlItemRow& output) { @@ -138,3 +137,13 @@ std::pair DistinctCollectExecutor::expectedNumberOfRows( // but it is upper bounded by the input. return _fetcher.preFetchNumberOfRows(atMost); } + +void DistinctCollectExecutor::destroyValues() { + // destroy all AqlValues captured + for (auto& it : _seen) { + for (auto& it2 : it) { + const_cast(&it2)->destroy(); + } + } + _seen.clear(); +} diff --git a/arangod/Aql/DistinctCollectExecutor.h b/arangod/Aql/DistinctCollectExecutor.h index 2a2c322d76..f14349a3ff 100644 --- a/arangod/Aql/DistinctCollectExecutor.h +++ b/arangod/Aql/DistinctCollectExecutor.h @@ -95,6 +95,8 @@ class DistinctCollectExecutor { DistinctCollectExecutor(DistinctCollectExecutor const&) = delete; DistinctCollectExecutor(Fetcher& fetcher, Infos&); ~DistinctCollectExecutor(); + + void initializeCursor(); /** * @brief produce the next Row of Aql Values. @@ -107,6 +109,7 @@ class DistinctCollectExecutor { private: Infos const& infos() const noexcept { return _infos; }; + void destroyValues(); private: Infos const& _infos; diff --git a/arangod/Aql/ExecutionBlockImpl.cpp b/arangod/Aql/ExecutionBlockImpl.cpp index 7c8272f041..e0e79ce64b 100644 --- a/arangod/Aql/ExecutionBlockImpl.cpp +++ b/arangod/Aql/ExecutionBlockImpl.cpp @@ -372,6 +372,9 @@ std::pair ExecutionBlockImpl::initializeCursor static_assert(!std::is_same::value || customInit, "IndexExecutor is expected to implement a custom " "initializeCursor method!"); + static_assert(!std::is_same::value || customInit, + "DistinctCollectExecutor is expected to implement a custom " + "initializeCursor method!"); InitializeCursor::init(_executor, _rowFetcher, _infos); // // use this with c++17 instead of specialisation below