1
0
Fork 0

adding remainingForShard to ScatterBlock

This commit is contained in:
James 2014-10-02 10:03:08 +01:00
parent 6e7f4c7501
commit 2f887e197e
2 changed files with 37 additions and 1 deletions

View File

@ -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<size_t,size_t> 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 <shardId>?
////////////////////////////////////////////////////////////////////////////////

View File

@ -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 <shardId>?
////////////////////////////////////////////////////////////////////////////////
int64_t remainingForShard (std::string const& shardId);
////////////////////////////////////////////////////////////////////////////////
/// @brief getOrSkipSomeForShard