File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 23
23
24
24
#pragma once
25
25
26
- #include " Basics/Common.h"
27
26
#include " Basics/debugging.h"
28
27
29
28
#include < velocypack/Builder.h>
@@ -49,23 +48,31 @@ class ModificationExecutorAccumulator {
49
48
return _accumulator.slice ();
50
49
}
51
50
52
- void add (VPackSlice const & doc) {
51
+ void add (VPackSlice doc) {
53
52
TRI_ASSERT (_accumulator.isOpenArray ());
54
53
_accumulator.add (doc);
54
+ ++_nrOfDocuments;
55
55
}
56
56
57
57
void reset () {
58
58
_accumulator.clear ();
59
- _accumulator.openArray ();
59
+ _accumulator.openArray (/* unindexed*/ true );
60
+ _nrOfDocuments = 0 ;
60
61
}
61
62
62
- [[nodiscard]] size_t nrOfDocuments () const {
63
+ [[nodiscard]] size_t nrOfDocuments () const noexcept {
63
64
TRI_ASSERT (_accumulator.isClosed ());
64
- return _accumulator. slice (). length () ;
65
+ return _nrOfDocuments ;
65
66
}
66
67
67
68
private:
68
69
VPackBuilder _accumulator{};
70
+ // storing the number of documents separately allows us
71
+ // to return the value without having to call slice().length()
72
+ // on the Builder. it also allows us to use a compact velocypack
73
+ // array inside the Builder without an index table (smaller
74
+ // size, less overhead when closing the array).
75
+ size_t _nrOfDocuments{0 };
69
76
};
70
77
71
78
} // namespace arangodb::aql
You can’t perform that action at this time.
0 commit comments