From e36655dee7fdfde772dc48c6269a4c842a8b26b1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 14 May 2019 13:19:09 +0200 Subject: [PATCH] Feature/have collection count type (#8942) --- arangod/Aql/AqlItemBlock.cpp | 2 +- arangod/Aql/AqlItemBlock.h | 2 +- arangod/Aql/ConstrainedSortExecutor.h | 2 +- arangod/Aql/ExecutionBlockImpl.cpp | 2 +- arangod/Aql/ExecutionBlockImpl.h | 2 +- arangod/Aql/types.h | 1 + tests/Aql/AqlItemBlockHelper.cpp | 2 +- tests/Aql/RowFetcherHelper.cpp | 6 +++--- tests/Aql/RowFetcherHelper.h | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arangod/Aql/AqlItemBlock.cpp b/arangod/Aql/AqlItemBlock.cpp index f53e251242..376906d5ec 100644 --- a/arangod/Aql/AqlItemBlock.cpp +++ b/arangod/Aql/AqlItemBlock.cpp @@ -423,7 +423,7 @@ SharedAqlItemBlockPtr AqlItemBlock::slice(size_t from, size_t to) const { /// @brief slice/clone, this does a deep copy of all entries SharedAqlItemBlockPtr AqlItemBlock::slice(size_t row, std::unordered_set const& registers, - size_t newNrRegs) const { + RegisterCount newNrRegs) const { TRI_ASSERT(_nrRegs <= newNrRegs); std::unordered_set cache; diff --git a/arangod/Aql/AqlItemBlock.h b/arangod/Aql/AqlItemBlock.h index 78644021a6..a5076fb04f 100644 --- a/arangod/Aql/AqlItemBlock.h +++ b/arangod/Aql/AqlItemBlock.h @@ -332,7 +332,7 @@ class AqlItemBlock { /// @brief create an AqlItemBlock with a single row, with copies of the /// specified registers from the current block SharedAqlItemBlockPtr slice(size_t row, std::unordered_set const& registers, - size_t newNrRegs) const; + RegisterCount newNrRegs) const; /// @brief slice/clone chosen rows for a subset, this does a deep copy /// of all entries diff --git a/arangod/Aql/ConstrainedSortExecutor.h b/arangod/Aql/ConstrainedSortExecutor.h index 4cf55d56be..0950dc34fc 100644 --- a/arangod/Aql/ConstrainedSortExecutor.h +++ b/arangod/Aql/ConstrainedSortExecutor.h @@ -93,7 +93,7 @@ class ConstrainedSortExecutor { Fetcher& _fetcher; ExecutionState _state; size_t _returnNext; - std::vector _rows; + std::vector _rows; size_t _rowsPushed; SharedAqlItemBlockPtr _heapBuffer; std::unique_ptr _cmpHeap; // in pointer to avoid diff --git a/arangod/Aql/ExecutionBlockImpl.cpp b/arangod/Aql/ExecutionBlockImpl.cpp index 8454fc9b82..6770accf11 100644 --- a/arangod/Aql/ExecutionBlockImpl.cpp +++ b/arangod/Aql/ExecutionBlockImpl.cpp @@ -498,7 +498,7 @@ std::pair ExecutionBlockImpl>::s template std::pair ExecutionBlockImpl::requestWrappedBlock( - size_t nrItems, RegisterId nrRegs) { + size_t nrItems, RegisterCount nrRegs) { SharedAqlItemBlockPtr block; if /* constexpr */ (Executor::Properties::allowsBlockPassthrough) { // If blocks can be passed through, we do not create new blocks. diff --git a/arangod/Aql/ExecutionBlockImpl.h b/arangod/Aql/ExecutionBlockImpl.h index a1a9b3de67..6806036322 100644 --- a/arangod/Aql/ExecutionBlockImpl.h +++ b/arangod/Aql/ExecutionBlockImpl.h @@ -208,7 +208,7 @@ class ExecutionBlockImpl final : public ExecutionBlock { Executor& executor() { return _executor; } /// @brief request an AqlItemBlock from the memory manager - SharedAqlItemBlockPtr requestBlock(size_t nrItems, RegisterId nrRegs); + SharedAqlItemBlockPtr requestBlock(size_t nrItems, RegisterCount nrRegs); private: /** diff --git a/arangod/Aql/types.h b/arangod/Aql/types.h index 336cc56f6c..c952a957f9 100644 --- a/arangod/Aql/types.h +++ b/arangod/Aql/types.h @@ -35,6 +35,7 @@ typedef uint32_t VariableId; /// @brief type for register numbers/ids typedef unsigned int RegisterId; +typedef RegisterId RegisterCount; /// @brief type of a query id typedef uint64_t QueryId; diff --git a/tests/Aql/AqlItemBlockHelper.cpp b/tests/Aql/AqlItemBlockHelper.cpp index d72af01346..3c38ca8f0e 100644 --- a/tests/Aql/AqlItemBlockHelper.cpp +++ b/tests/Aql/AqlItemBlockHelper.cpp @@ -25,7 +25,7 @@ std::ostream& std::operator<<( std::ostream& out, ::arangodb::aql::AqlItemBlock const& block) { for (size_t i = 0; i < block.size(); i++) { - for (size_t j = 0; j < block.getNrRegs(); j++) { + for (arangodb::aql::RegisterCount j = 0; j < block.getNrRegs(); j++) { out << block.getValue(i, j).slice().toJson(); if (j + 1 != block.getNrRegs()) out << ", "; } diff --git a/tests/Aql/RowFetcherHelper.cpp b/tests/Aql/RowFetcherHelper.cpp index 1894e870ea..646d5ff8ad 100644 --- a/tests/Aql/RowFetcherHelper.cpp +++ b/tests/Aql/RowFetcherHelper.cpp @@ -92,7 +92,7 @@ SingleRowFetcherHelper::SingleRowFetcherHelper( if (_nrItems > 0) { VPackSlice oneRow = _data.at(0); REQUIRE(oneRow.isArray()); - uint64_t nrRegs = oneRow.length(); + arangodb::aql::RegisterCount nrRegs = static_cast(oneRow.length()); // Add all registers as valid input registers: auto inputRegisters = std::make_shared>(); for (RegisterId i = 0; i < nrRegs; i++) { @@ -187,7 +187,7 @@ AllRowsFetcherHelper::AllRowsFetcherHelper(std::shared_ptr> if (_nrItems > 0) { VPackSlice oneRow = _data.at(0); REQUIRE(oneRow.isArray()); - _nrRegs = oneRow.length(); + _nrRegs = static_cast(oneRow.length()); SharedAqlItemBlockPtr itemBlock{new AqlItemBlock(_itemBlockManager, _nrItems, _nrRegs)}; VPackToAqlItemBlock(_data, _nrRegs, *itemBlock); // Add all registers as valid input registers: @@ -242,7 +242,7 @@ ConstFetcherHelper::ConstFetcherHelper(AqlItemBlockManager& itemBlockManager, if (nrItems > 0) { VPackSlice oneRow = _data.at(0); REQUIRE(oneRow.isArray()); - uint64_t nrRegs = oneRow.length(); + arangodb::aql::RegisterCount nrRegs = static_cast(oneRow.length()); auto inputRegisters = std::make_shared>(); for (RegisterId i = 0; i < nrRegs; i++) { inputRegisters->emplace(i); diff --git a/tests/Aql/RowFetcherHelper.h b/tests/Aql/RowFetcherHelper.h index 4f734b6728..ec37ea0673 100644 --- a/tests/Aql/RowFetcherHelper.h +++ b/tests/Aql/RowFetcherHelper.h @@ -105,7 +105,7 @@ class AllRowsFetcherHelper : public ::arangodb::aql::AllRowsFetcher { bool _returnedDone = false; bool _returnsWaiting; uint64_t _nrItems; - uint64_t _nrRegs; + arangodb::aql::RegisterCount _nrRegs; uint64_t _nrCalled; arangodb::aql::ResourceMonitor _resourceMonitor; arangodb::aql::AqlItemBlockManager _itemBlockManager;