10000 use a compact velocypack array in ModificationExecutorAccumulator (#1… · cloudhub-js/arangodb@a7169c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit a7169c2

Browse files
authored
use a compact velocypack array in ModificationExecutorAccumulator (arangodb#17876)
1 parent 79a4679 commit a7169c2

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

arangod/Aql/ModificationExecutorAccumulator.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#pragma once
2525

26-
#include "Basics/Common.h"
2726
#include "Basics/debugging.h"
2827

2928
#include <velocypack/Builder.h>
@@ -49,23 +48,31 @@ class ModificationExecutorAccumulator {
4948
return _accumulator.slice();
5049
}
5150

52-
void add(VPackSlice const& doc) {
51+
void add(VPackSlice doc) {
5352
TRI_ASSERT(_accumulator.isOpenArray());
5453
_accumulator.add(doc);
54+
++_nrOfDocuments;
5555
}
5656

5757
void reset() {
5858
_accumulator.clear();
59-
_accumulator.openArray();
59+
_accumulator.openArray(/*unindexed*/ true);
60+
_nrOfDocuments = 0;
6061
}
6162

62-
[[nodiscard]] size_t nrOfDocuments() const {
63+
[[nodiscard]] size_t nrOfDocuments() const noexcept {
6364
TRI_ASSERT(_accumulator.isClosed());
64-
return _accumulator.slice().length();
65+
return _nrOfDocuments;
6566
}
6667

6768
private:
6869
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};
6976
};
7077

7178
} // namespace arangodb::aql

0 commit comments

Comments
 (0)
0