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