1
0
Fork 0

Merge branch 'engine-api' of https://github.com/arangodb/arangodb into engine-api

* 'engine-api' of https://github.com/arangodb/arangodb:
  Added RocksDBPrimaryMockIndexIterator
This commit is contained in:
Jan Christoph Uhde 2017-03-28 14:52:59 +02:00
commit 31c52f60ff
2 changed files with 15 additions and 6 deletions

View File

@ -78,20 +78,27 @@ RocksDBAllIndexIterator::RocksDBAllIndexIterator(
ManagedDocumentResult* mmdr, RocksDBPrimaryMockIndex const* index, ManagedDocumentResult* mmdr, RocksDBPrimaryMockIndex const* index,
bool reverse) bool reverse)
: IndexIterator(collection, trx, mmdr, index), : 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) { 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 // No limit no data, or we are actually done. The last call should have
// returned false // returned false
TRI_ASSERT(limit > 0); // Someone called with limit == 0. Api broken TRI_ASSERT(limit > 0); // Someone called with limit == 0. Api broken
return false; 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() { void RocksDBAllIndexIterator::reset() {

View File

@ -85,6 +85,7 @@ class RocksDBAllIndexIterator final : public IndexIterator {
private: private:
bool const _reverse; bool const _reverse;
std::unordered_map<std::string, TRI_voc_rid_t>::const_iterator _iterator; std::unordered_map<std::string, TRI_voc_rid_t>::const_iterator _iterator;
std::unordered_map<std::string, TRI_voc_rid_t>::const_iterator _end;
//uint64_t _total; //uint64_t _total;
}; };
@ -105,6 +106,7 @@ class RocksDBAnyIndexIterator final : public IndexIterator {
class RocksDBPrimaryMockIndex final : public Index { class RocksDBPrimaryMockIndex final : public Index {
friend class RocksDBPrimaryMockIndexIterator; friend class RocksDBPrimaryMockIndexIterator;
friend class RocksDBAllIndexIterator;
public: public:
RocksDBPrimaryMockIndex() = delete; RocksDBPrimaryMockIndex() = delete;