1
0
Fork 0

optimizations

This commit is contained in:
Jan Steemann 2014-12-04 16:33:48 +01:00
parent f3b3e5d932
commit cc00bb8897
3 changed files with 29 additions and 8 deletions

View File

@ -103,6 +103,15 @@ namespace triagens {
TRI_ASSERT(_data.capacity() > index * _nrRegs + varNr);
return _data[index * _nrRegs + varNr];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief getValue, get the value of a register by reference
////////////////////////////////////////////////////////////////////////////////
AqlValue const& getValueReference (size_t index, RegisterId varNr) const {
TRI_ASSERT(_data.capacity() > index * _nrRegs + varNr);
return _data[index * _nrRegs + varNr];
}
////////////////////////////////////////////////////////////////////////////////
/// @brief setValue, set the current value of a register

View File

@ -756,17 +756,21 @@ AqlValue AqlValue::CreateFromBlocks (triagens::arango::AqlTransaction* trx,
for (auto it = src.begin(); it != src.end(); ++it) {
auto current = (*it);
RegisterId const n = current->getNrRegs();
std::vector<std::pair<RegisterId, TRI_document_collection_t const*>> registers;
for (RegisterId j = 0; j < n; ++j) {
// temporaries don't have a name and won't be included
if (variableNames[j][0] != '\0') {
registers.emplace_back(std::make_pair(j, current->getDocumentCollection(j)));
}
}
for (size_t i = 0; i < current->size(); ++i) {
Json values(Json::Array);
Json values(Json::Array, registers.size());
for (RegisterId j = 0; j < n; ++j) {
if (variableNames[j][0] != '\0') {
// temporaries don't have a name and won't be included
// Variables from depth 0 are excluded, too, unless the
// COLLECT statement is on level 0 as well.
values.set(variableNames[j].c_str(), current->getValue(i, j).toJson(trx, current->getDocumentCollection(j)));
}
// only enumerate the registers that are left
for (auto const& reg : registers) {
values.set(variableNames[reg.first], current->getValueReference(i, reg.first).toJson(trx, reg.second));
}
json->add(values);

View File

@ -702,6 +702,14 @@ namespace triagens {
TRI_Insert3ArrayJson(_zone, _json, name, sub.steal());
return *this;
}
Json& set (std::string const& name, Json sub) {
if (! TRI_IsArrayJson(_json)) {
throw JsonException("Json is no array");
}
TRI_Insert3ArrayJson(_zone, _json, name.c_str(), sub.steal());
return *this;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief this is a syntactic shortcut for the set method using operator()