diff --git a/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.cpp b/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.cpp index bafab68fcc..26db4d5402 100644 --- a/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.cpp +++ b/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.cpp @@ -53,7 +53,7 @@ RocksDBPrimaryMockIndexIterator::RocksDBPrimaryMockIndexIterator( : IndexIterator(collection, trx, mmdr, index), _index(index), _keys(keys.get()), - _iterator(_keys->slice()) { + _iterator(_keys->slice()){ keys.release(); // now we have ownership for _keys TRI_ASSERT(_keys->slice().isArray()); } @@ -75,23 +75,30 @@ void RocksDBPrimaryMockIndexIterator::reset() { _iterator.reset(); } RocksDBAllIndexIterator::RocksDBAllIndexIterator( LogicalCollection* collection, transaction::Methods* trx, - ManagedDocumentResult* mmdr, RocksDBPrimaryMockIndex const* index, + ManagedDocumentResult* mmdr, RocksDBPrimaryMockIndex const* index, bool reverse) : IndexIterator(collection, trx, mmdr, index), - _reverse(reverse) {} + _reverse(reverse), + _iterator(index->_keyRevMap.begin()), + _end(index->_keyRevMap.end()) {} bool RocksDBAllIndexIterator::next(TokenCallback const& cb, size_t limit) { - if (limit == 0 ) {//|| !_iterator.valid() + if (limit == 0 || _iterator == _end) { // No limit no data, or we are actually done. The last call should have // returned false TRI_ASSERT(limit > 0); // Someone called with limit == 0. Api broken return false; } - while (limit > 0) { + while (limit > 0 && _iterator != _end) { + TRI_voc_rid_t revisionId = _iterator->second; + cb(RocksDBToken(revisionId)); + + limit--; + _iterator++; } - return false; + return _iterator != _end; } void RocksDBAllIndexIterator::reset() { diff --git a/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.h b/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.h index c25c053172..da5aececf3 100644 --- a/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.h +++ b/arangod/RocksDBEngine/RocksDBPrimaryMockIndex.h @@ -85,6 +85,7 @@ class RocksDBAllIndexIterator final : public IndexIterator { private: bool const _reverse; std::unordered_map::const_iterator _iterator; + std::unordered_map::const_iterator _end; //uint64_t _total; }; @@ -105,6 +106,7 @@ class RocksDBAnyIndexIterator final : public IndexIterator { class RocksDBPrimaryMockIndex final : public Index { friend class RocksDBPrimaryMockIndexIterator; + friend class RocksDBAllIndexIterator; public: RocksDBPrimaryMockIndex() = delete;