mirror of https://gitee.com/bigwinds/arangodb
use value by reference
This commit is contained in:
parent
6c66320de8
commit
b46db8ed20
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3563,7 +3563,7 @@ int HashedAggregateBlock::getOrSkipSome (size_t atLeast,
|
|||
}
|
||||
|
||||
std::unordered_map<std::vector<AqlValue>, 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++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue