From b46db8ed2069bee882dc6f1dd78bfd294236d91f Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 20 Apr 2015 16:10:31 +0200 Subject: [PATCH] use value by reference --- arangod/Aql/AqlValue.h | 5 +++-- arangod/Aql/ExecutionBlock.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arangod/Aql/AqlValue.h b/arangod/Aql/AqlValue.h index bcde258f61..ffdd21b18b 100644 --- a/arangod/Aql/AqlValue.h +++ b/arangod/Aql/AqlValue.h @@ -100,7 +100,8 @@ namespace triagens { } AqlValue (int64_t low, int64_t high) - : _type(RANGE) { + : _range(nullptr), + _type(RANGE) { _range = new Range(low, high); } @@ -160,7 +161,7 @@ namespace triagens { /// is used when the AqlValue is stolen and stored in another object //////////////////////////////////////////////////////////////////////////////// - void erase () { + void erase () throw() { _type = EMPTY; _json = nullptr; } diff --git a/arangod/Aql/ExecutionBlock.cpp b/arangod/Aql/ExecutionBlock.cpp index a4f198c094..492c3fd358 100644 --- a/arangod/Aql/ExecutionBlock.cpp +++ b/arangod/Aql/ExecutionBlock.cpp @@ -3563,7 +3563,7 @@ int HashedAggregateBlock::getOrSkipSome (size_t atLeast, } std::unordered_map, size_t, GroupKeyHash, GroupKeyEqual> allGroups( - 256, + 1024, GroupKeyHash(_trx, colls), GroupKeyEqual(_trx, colls) ); @@ -3621,26 +3621,27 @@ int HashedAggregateBlock::getOrSkipSome (size_t atLeast, while (skipped < atMost) { groupValues.clear(); + // for hashing simply re-use the aggregate registers, without cloning their contents for (size_t i = 0; i < n; ++i) { groupValues.emplace_back(cur->getValueReference(_pos, _aggregateRegisters[i].second)); } - + // now check if we already know this group auto it = allGroups.find(groupValues); if (it == allGroups.end()) { // new group group.clear(); - - // copy the group values + + // copy the group values before they get invalidated for (size_t i = 0; i < n; ++i) { - group.emplace_back(cur->getValue(_pos, _aggregateRegisters[i].second).clone()); + group.emplace_back(cur->getValueReference(_pos, _aggregateRegisters[i].second).clone()); } allGroups.emplace(group, 1); } else { - // existing group + // existing group. simply increase the counter (*it).second++; }