From 2f887e197e971f8c0c480e274deec7e282427dfe Mon Sep 17 00:00:00 2001 From: James Date: Thu, 2 Oct 2014 10:03:08 +0100 Subject: [PATCH 1/2] adding remainingForShard to ScatterBlock --- arangod/Aql/ExecutionBlock.cpp | 30 ++++++++++++++++++++++++++++++ arangod/Aql/ExecutionBlock.h | 8 +++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index 441678f57f..baea4a4379 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -3638,6 +3638,36 @@ bool ScatterBlock::hasMore () { return false; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief remainingForShard: remaining for shard, sum of the number of row left +/// in the buffer and _dependencies[0]->remaining() +//////////////////////////////////////////////////////////////////////////////// + +int64_t ScatterBlock::remainingForShard (std::string const& shardId) { + + size_t clientId = getClientId(shardId); + + if (_doneForClient.at(clientId)) { + return 0; + } + + int64_t sum = _dependencies[0]->remaining(); + if (sum == -1) { + return -1; + } + + std::pair pos = _posForClient.at(clientId); + + if (pos.first <= _buffer.size()) { + sum += _buffer.at(pos.first)->size() - pos.second; + for (auto i = pos.first + 1; i < _buffer.size(); i++) { + sum += _buffer.at(i)->size(); + } + } + + return sum; +} + //////////////////////////////////////////////////////////////////////////////// /// @brief hasMoreForShard: any more for shard ? //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Aql/ExecutionBlock.h b/arangod/Aql/ExecutionBlock.h index db4ebe03f0..90b3311566 100644 --- a/arangod/Aql/ExecutionBlock.h +++ b/arangod/Aql/ExecutionBlock.h @@ -1574,7 +1574,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// int64_t remaining () { - return _dependencies[0]->remaining(); + TRI_ASSERT(false); } //////////////////////////////////////////////////////////////////////////////// @@ -1606,6 +1606,12 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// bool hasMoreForShard (std::string const& shardId); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief remainingForShard: remaining for shard ? +//////////////////////////////////////////////////////////////////////////////// + + int64_t remainingForShard (std::string const& shardId); //////////////////////////////////////////////////////////////////////////////// /// @brief getOrSkipSomeForShard From 16d54d6694adca31d53d4cdffca83706f4012d99 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 2 Oct 2014 10:06:45 +0100 Subject: [PATCH 2/2] snapshot --- arangod/Aql/OptimizerRules.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arangod/Aql/OptimizerRules.cpp b/arangod/Aql/OptimizerRules.cpp index 2f0be63a18..60a26a92d0 100644 --- a/arangod/Aql/OptimizerRules.cpp +++ b/arangod/Aql/OptimizerRules.cpp @@ -1998,6 +1998,7 @@ class RemoveToEnumCollFinder: public WalkerWorker { } bool before (ExecutionNode* en) { + std::cout << "before!\n"; switch (en->getType()) { case EN::REMOVE:{ TRI_ASSERT(_remove == false); @@ -2013,10 +2014,10 @@ class RemoveToEnumCollFinder: public WalkerWorker { _variable = varsToRemove[0]; // the variable we'll remove auto _enumColl = static_cast(_plan->getVarSetBy(_variable->id)); - + if (_enumColl == nullptr - || _enumColl->getType() != triagens::aql::ExecutionNode::ENUMERATE_COLLECTION - || _enumColl->collection()->cid() != rn->collection()->cid() ) { + || _enumColl->getType() != triagens::aql::ExecutionNode::ENUMERATE_COLLECTION ) { + // || _enumColl->collection()->cid() != rn->collection()->cid() ) { // remove variable was not introduced by an enumerate collection or // it was but the collections differ break; // abort . . . @@ -2057,6 +2058,10 @@ class RemoveToEnumCollFinder: public WalkerWorker { _toUnlink.insert(en); return false; // continue . . . } + + case EN::CALCULATION: {//Check this is the calculation node of one of the filter nodes! + + } case EN::ENUMERATE_COLLECTION: { // check that we are enumerating the variable we are to remove if (en->id() != _enumColl->id()) { @@ -2067,7 +2072,6 @@ class RemoveToEnumCollFinder: public WalkerWorker { } case EN::SINGLETON: - case EN::CALCULATION: case EN::ENUMERATE_LIST: case EN::SUBQUERY: case EN::AGGREGATE: