diff --git a/arangod/Utils/Transaction.h b/arangod/Utils/Transaction.h index ce1e0310a7..acc99637a6 100644 --- a/arangod/Utils/Transaction.h +++ b/arangod/Utils/Transaction.h @@ -427,9 +427,12 @@ namespace triagens { docs.reserve(batchSize); } TRI_ASSERT(batchSize > 0); + + auto primaryIndex = document->primaryIndex(); while (count < batchSize) { - TRI_doc_mptr_t const* mptr = document->primaryIndex()->lookupSequential(internalSkip, total); + TRI_doc_mptr_t const* mptr = primaryIndex->lookupSequential(internalSkip, total); + if (mptr == nullptr) { break; } @@ -438,6 +441,7 @@ namespace triagens { } else { docs.emplace_back(*mptr); + if (++count >= limit) { break; } diff --git a/lib/Basics/AssocUnique.h b/lib/Basics/AssocUnique.h index 4ed950d34a..4ab28693cf 100644 --- a/lib/Basics/AssocUnique.h +++ b/lib/Basics/AssocUnique.h @@ -265,7 +265,7 @@ namespace triagens { /// the second bucket at Position 2 (7 - Bucket1.size()) //////////////////////////////////////////////////////////////////////////////// - Element* findElementSequentialBucktes (uint64_t position) const { + Element* findElementSequentialBuckets (uint64_t position) const { for (auto& b : _buckets) { if (position >= b._nrAlloc) { position -= b._nrAlloc; @@ -754,7 +754,7 @@ namespace triagens { Element* res = nullptr; do { - res = findElementSequentialBucktes(position); + res = findElementSequentialBuckets(position); position++; } while (position < total && res == nullptr); @@ -785,7 +785,7 @@ namespace triagens { Element* res = nullptr; do { - res = findElementSequentialBucktes(position); + res = findElementSequentialBuckets(position); position--; } while (position > 0 && res == nullptr); @@ -835,7 +835,7 @@ namespace triagens { // Find documents Element* res = nullptr; do { - res = findElementSequentialBucktes(position); + res = findElementSequentialBuckets(position); position += step; position = position % total; }