From a624ea4ec5bcd815cedbd4ac485ca545f1492e4b Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 1 Jun 2016 16:23:32 +0200 Subject: [PATCH] attempt to fix PrimaryIndexIterator::nextBabies() --- arangod/Indexes/PrimaryIndex.cpp | 36 ++++++++++++++++++++++++++++++++ arangod/Indexes/PrimaryIndex.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/arangod/Indexes/PrimaryIndex.cpp b/arangod/Indexes/PrimaryIndex.cpp index 2f5e329d1b..c8f5429511 100644 --- a/arangod/Indexes/PrimaryIndex.cpp +++ b/arangod/Indexes/PrimaryIndex.cpp @@ -93,6 +93,25 @@ TRI_doc_mptr_t* PrimaryIndexIterator::next() { return nullptr; } +void PrimaryIndexIterator::nextBabies(std::vector& buffer, size_t limit) { + size_t atMost = limit; + + buffer.clear(); + + while (_iterator.valid() && atMost > 0) { + auto result = _index->lookup(_trx, _iterator.value()); + _iterator.next(); + + if (result == nullptr) { + return; + } + + buffer.emplace_back(result); + --atMost; + } +} + + void PrimaryIndexIterator::reset() { _iterator.reset(); } TRI_doc_mptr_t* AllIndexIterator::next() { @@ -102,6 +121,23 @@ TRI_doc_mptr_t* AllIndexIterator::next() { return _index->findSequential(_trx, _position, _total); }; +void AllIndexIterator::nextBabies(std::vector& buffer, size_t limit) { + size_t atMost = limit; + + buffer.clear(); + + while (atMost > 0) { + auto result = next(); + + if (result == nullptr) { + return; + } + + buffer.emplace_back(result); + --atMost; + } +} + void AllIndexIterator::reset() { _position.reset(); } TRI_doc_mptr_t* AnyIndexIterator::next() { diff --git a/arangod/Indexes/PrimaryIndex.h b/arangod/Indexes/PrimaryIndex.h index 4a27c622c5..aeed4fba58 100644 --- a/arangod/Indexes/PrimaryIndex.h +++ b/arangod/Indexes/PrimaryIndex.h @@ -56,6 +56,8 @@ class PrimaryIndexIterator final : public IndexIterator { ~PrimaryIndexIterator() {} TRI_doc_mptr_t* next() override; + + void nextBabies(std::vector&, size_t) override; void reset() override; @@ -79,6 +81,8 @@ class AllIndexIterator final : public IndexIterator { ~AllIndexIterator() {} TRI_doc_mptr_t* next() override; + + void nextBabies(std::vector&, size_t) override; void reset() override;