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

@ -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() {

View File

@ -85,6 +85,7 @@ class RocksDBAllIndexIterator final : public IndexIterator {
private:
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 _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;