From 922a96fee0553dda00e46f021d9c48f85457240e Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Tue, 1 Mar 2016 16:37:21 +0100 Subject: [PATCH] Added a reset function to OperationCursor. ALso added a switch to getMore to define that all documents are referenced as Externals instead of inplace --- arangod/Utils/OperationCursor.cpp | 15 +++++++++++++-- arangod/Utils/OperationCursor.h | 8 +++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arangod/Utils/OperationCursor.cpp b/arangod/Utils/OperationCursor.cpp index f884575ed0..d729ca4bfd 100644 --- a/arangod/Utils/OperationCursor.cpp +++ b/arangod/Utils/OperationCursor.cpp @@ -25,6 +25,11 @@ using namespace arangodb; + +void OperationCursor::reset() { + _indexIterator->reset(); +} + ////////////////////////////////////////////////////////////////////////////// /// @brief Get next default batchSize many elements. /// Check hasMore()==true before using this @@ -38,10 +43,12 @@ int OperationCursor::getMore() { ////////////////////////////////////////////////////////////////////////////// /// @brief Get next batchSize many elements. /// Check hasMore()==true before using this +/// If useExternals is set to true all elements in the vpack are +/// externals. Otherwise they are inlined. /// NOTE: This will throw on OUT_OF_MEMORY ////////////////////////////////////////////////////////////////////////////// -int OperationCursor::getMore(uint64_t batchSize) { +int OperationCursor::getMore(uint64_t batchSize, bool useExternals) { // This may throw out of memory if (!hasMore()) { TRI_ASSERT(false); @@ -56,7 +63,11 @@ int OperationCursor::getMore(uint64_t batchSize) { while (batchSize > 0 && _limit > 0 && (mptr = _indexIterator->next()) != nullptr) { --batchSize; --_limit; - _builder.add(VPackSlice(mptr->vpack())); + if (useExternals) { + _builder.add(VPackValue(mptr->vpack(), VPackValueType::External)); + } else { + _builder.add(VPackSlice(mptr->vpack())); + } } if (batchSize > 0 || _limit == 0) { // Iterator empty, there is no more diff --git a/arangod/Utils/OperationCursor.h b/arangod/Utils/OperationCursor.h index fdf58f8445..9c33b6d875 100644 --- a/arangod/Utils/OperationCursor.h +++ b/arangod/Utils/OperationCursor.h @@ -94,13 +94,19 @@ struct OperationCursor : public OperationResult { return _hasMore; } +////////////////////////////////////////////////////////////////////////////// +/// @brief Reset the cursor +////////////////////////////////////////////////////////////////////////////// + + void reset(); + ////////////////////////////////////////////////////////////////////////////// /// @brief Get next batchSize many elements. /// Check hasMore()==true before using this /// NOTE: This will throw on OUT_OF_MEMORY ////////////////////////////////////////////////////////////////////////////// - int getMore(uint64_t); + int getMore(uint64_t, bool useExternals = false); ////////////////////////////////////////////////////////////////////////////// /// @brief Get next default batchSize many elements.