1
0
Fork 0

Added a mapping for Traverser cursor ids.

This commit is contained in:
Michael Hackstein 2016-10-11 11:03:36 +02:00
parent 001407d312
commit 053e7fcc6b
2 changed files with 28 additions and 6 deletions

View File

@ -54,8 +54,13 @@ static int FetchDocumentById(arangodb::Transaction* trx,
return res;
}
SingleServerEdgeCursor::SingleServerEdgeCursor(size_t nrCursors)
: _cursors(), _currentCursor(0), _currentSubCursor(0), _cachePos(0) {
SingleServerEdgeCursor::SingleServerEdgeCursor(
size_t nrCursors, std::vector<size_t> const* mapping)
: _cursors(),
_currentCursor(0),
_currentSubCursor(0),
_cachePos(0),
_internalCursorMapping(mapping) {
_cursors.reserve(nrCursors);
_cache.reserve(1000);
};
@ -68,7 +73,12 @@ bool SingleServerEdgeCursor::next(std::vector<VPackSlice>& result,
_cachePos++;
if (_cachePos < _cache.size()) {
result.emplace_back(_cache[_cachePos]->vpack());
cursorId = _currentCursor;
if (_internalCursorMapping != nullptr) {
TRI_ASSERT(_currentCursor < _internalCursorMapping->size());
cursorId = _internalCursorMapping->at(_currentCursor);
} else {
cursorId = _currentCursor;
}
return true;
}
// We need to refill the cache.
@ -108,7 +118,12 @@ bool SingleServerEdgeCursor::next(std::vector<VPackSlice>& result,
} while (_cache.empty());
TRI_ASSERT(_cachePos < _cache.size());
result.emplace_back(_cache[_cachePos]->vpack());
cursorId = _currentCursor;
if (_internalCursorMapping != nullptr) {
TRI_ASSERT(_currentCursor < _internalCursorMapping->size());
cursorId = _internalCursorMapping->at(_currentCursor);
} else {
cursorId = _currentCursor;
}
return true;
}
@ -117,7 +132,12 @@ bool SingleServerEdgeCursor::readAll(std::unordered_set<VPackSlice>& result,
if (_currentCursor >= _cursors.size()) {
return false;
}
cursorId = _currentCursor;
if (_internalCursorMapping != nullptr) {
TRI_ASSERT(_currentCursor < _internalCursorMapping->size());
cursorId = _internalCursorMapping->at(_currentCursor);
} else {
cursorId = _currentCursor;
}
auto& cursorSet = _cursors[_currentCursor];
for (auto& cursor : cursorSet) {
while (cursor->hasMore()) {

View File

@ -46,9 +46,11 @@ class SingleServerEdgeCursor : public EdgeCursor {
size_t _currentSubCursor;
std::vector<TRI_doc_mptr_t*> _cache;
size_t _cachePos;
std::vector<size_t> const* _internalCursorMapping;
public:
explicit SingleServerEdgeCursor(size_t);
explicit SingleServerEdgeCursor(size_t,
std::vector<size_t> const* mapping = nullptr);
~SingleServerEdgeCursor() {
for (auto& it : _cursors) {