mirror of https://gitee.com/bigwinds/arangodb
micro optimizations
This commit is contained in:
parent
c64b146d29
commit
578f3bb919
|
@ -165,7 +165,7 @@ AqlValue AqlValue::at(int64_t position, bool& mustDestroy,
|
||||||
}
|
}
|
||||||
if (position >= 0 && position < n) {
|
if (position >= 0 && position < n) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(s.at(position));
|
return AqlValue(s.at(position));
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -237,7 +237,7 @@ AqlValue AqlValue::getKeyAttribute(arangodb::AqlTransaction* trx,
|
||||||
VPackSlice found = Transaction::extractKeyFromDocument(s);
|
VPackSlice found = Transaction::extractKeyFromDocument(s);
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -278,7 +278,7 @@ AqlValue AqlValue::getIdAttribute(arangodb::AqlTransaction* trx,
|
||||||
}
|
}
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -314,7 +314,7 @@ AqlValue AqlValue::getFromAttribute(arangodb::AqlTransaction* trx,
|
||||||
VPackSlice found = Transaction::extractFromFromDocument(s);
|
VPackSlice found = Transaction::extractFromFromDocument(s);
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -350,7 +350,7 @@ AqlValue AqlValue::getToAttribute(arangodb::AqlTransaction* trx,
|
||||||
VPackSlice found = Transaction::extractToFromDocument(s);
|
VPackSlice found = Transaction::extractToFromDocument(s);
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -392,7 +392,7 @@ AqlValue AqlValue::get(arangodb::AqlTransaction* trx,
|
||||||
}
|
}
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
@ -434,7 +434,7 @@ AqlValue AqlValue::get(arangodb::AqlTransaction* trx,
|
||||||
}
|
}
|
||||||
if (!found.isNone()) {
|
if (!found.isNone()) {
|
||||||
if (doCopy) {
|
if (doCopy) {
|
||||||
mustDestroy = true;
|
mustDestroy = (type() == VPACK_MANAGED);
|
||||||
return AqlValue(found);
|
return AqlValue(found);
|
||||||
}
|
}
|
||||||
// return a reference to an existing slice
|
// return a reference to an existing slice
|
||||||
|
|
|
@ -32,12 +32,13 @@ using namespace arangodb::aql;
|
||||||
|
|
||||||
/// @brief create the accessor
|
/// @brief create the accessor
|
||||||
AttributeAccessor::AttributeAccessor(
|
AttributeAccessor::AttributeAccessor(
|
||||||
std::vector<std::string> const& attributeParts, Variable const* variable)
|
std::vector<std::string>&& attributeParts, Variable const* variable)
|
||||||
: _attributeParts(attributeParts),
|
: _attributeParts(attributeParts),
|
||||||
_variable(variable),
|
_variable(variable),
|
||||||
_type(EXTRACT_MULTI) {
|
_type(EXTRACT_MULTI) {
|
||||||
|
|
||||||
TRI_ASSERT(_variable != nullptr);
|
TRI_ASSERT(_variable != nullptr);
|
||||||
|
TRI_ASSERT(!_attributeParts.empty());
|
||||||
|
|
||||||
// determine accessor type
|
// determine accessor type
|
||||||
if (_attributeParts.size() == 1) {
|
if (_attributeParts.size() == 1) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct Variable;
|
||||||
/// @brief AttributeAccessor
|
/// @brief AttributeAccessor
|
||||||
class AttributeAccessor {
|
class AttributeAccessor {
|
||||||
public:
|
public:
|
||||||
AttributeAccessor(std::vector<std::string> const&, Variable const*);
|
AttributeAccessor(std::vector<std::string>&&, Variable const*);
|
||||||
~AttributeAccessor() = default;
|
~AttributeAccessor() = default;
|
||||||
|
|
||||||
/// @brief execute the accessor
|
/// @brief execute the accessor
|
||||||
|
|
|
@ -173,6 +173,8 @@ bool FilterBlock::getBlock(size_t atLeast, size_t atMost) {
|
||||||
|
|
||||||
_buffer.pop_front(); // Block was useless, just try again
|
_buffer.pop_front(); // Block was useless, just try again
|
||||||
delete cur; // free this block
|
delete cur; // free this block
|
||||||
|
|
||||||
|
throwIfKilled(); // check if we were aborted
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "Aql/SortNode.h"
|
#include "Aql/SortNode.h"
|
||||||
#include "Aql/TraversalNode.h"
|
#include "Aql/TraversalNode.h"
|
||||||
#include "Aql/WalkerWorker.h"
|
#include "Aql/WalkerWorker.h"
|
||||||
#include "Basics/StringBuffer.h"
|
|
||||||
|
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
using namespace arangodb::aql;
|
using namespace arangodb::aql;
|
||||||
|
|
|
@ -346,7 +346,7 @@ void Expression::analyzeExpression() {
|
||||||
auto v = static_cast<Variable const*>(member->getData());
|
auto v = static_cast<Variable const*>(member->getData());
|
||||||
|
|
||||||
// specialize the simple expression into an attribute accessor
|
// specialize the simple expression into an attribute accessor
|
||||||
_accessor = new AttributeAccessor(parts, v);
|
_accessor = new AttributeAccessor(std::move(parts), v);
|
||||||
_type = ATTRIBUTE;
|
_type = ATTRIBUTE;
|
||||||
_built = true;
|
_built = true;
|
||||||
}
|
}
|
||||||
|
@ -769,7 +769,6 @@ AqlValue Expression::executeSimpleExpressionFCall(
|
||||||
auto member = node->getMemberUnchecked(0);
|
auto member = node->getMemberUnchecked(0);
|
||||||
TRI_ASSERT(member->type == NODE_TYPE_ARRAY);
|
TRI_ASSERT(member->type == NODE_TYPE_ARRAY);
|
||||||
|
|
||||||
VPackBuilder builder;
|
|
||||||
size_t const n = member->numMembers();
|
size_t const n = member->numMembers();
|
||||||
|
|
||||||
VPackFunctionParameters parameters;
|
VPackFunctionParameters parameters;
|
||||||
|
@ -782,9 +781,7 @@ AqlValue Expression::executeSimpleExpressionFCall(
|
||||||
auto arg = member->getMemberUnchecked(i);
|
auto arg = member->getMemberUnchecked(i);
|
||||||
|
|
||||||
if (arg->type == NODE_TYPE_COLLECTION) {
|
if (arg->type == NODE_TYPE_COLLECTION) {
|
||||||
builder.clear();
|
parameters.emplace_back(AqlValue(arg->getString()));
|
||||||
builder.add(VPackValue(arg->getString()));
|
|
||||||
parameters.emplace_back(AqlValue(builder));
|
|
||||||
destroyParameters.push_back(true);
|
destroyParameters.push_back(true);
|
||||||
} else {
|
} else {
|
||||||
bool localMustDestroy;
|
bool localMustDestroy;
|
||||||
|
@ -1356,8 +1353,8 @@ AqlValue Expression::executeSimpleExpressionArithmetic(
|
||||||
return AqlValue(VelocyPackHelper::ZeroValue());
|
return AqlValue(VelocyPackHelper::ZeroValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
VPackBuilder builder;
|
TransactionBuilderLeaser builder(trx);
|
||||||
mustDestroy = true; // builder = dynamic data
|
mustDestroy = true; // builder = dynamic data
|
||||||
builder.add(VPackValue(result));
|
builder->add(VPackValue(result));
|
||||||
return AqlValue(builder);
|
return AqlValue(*builder.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,8 +533,14 @@ AqlItemBlock* IndexBlock::getSome(size_t atLeast, size_t atMost) {
|
||||||
// we do not need to do a lookup in
|
// we do not need to do a lookup in
|
||||||
// getPlanNode()->_registerPlan->varInfo,
|
// getPlanNode()->_registerPlan->varInfo,
|
||||||
// but can just take cur->getNrRegs() as registerId:
|
// but can just take cur->getNrRegs() as registerId:
|
||||||
res->setValue(j, static_cast<arangodb::aql::RegisterId>(curRegs),
|
auto doc = _documents[_posInDocs++];
|
||||||
AqlValue(_documents[_posInDocs++]));
|
if (doc.isExternal()) {
|
||||||
|
res->setValue(j, static_cast<arangodb::aql::RegisterId>(curRegs),
|
||||||
|
AqlValue(doc.resolveExternal().begin()));
|
||||||
|
} else {
|
||||||
|
res->setValue(j, static_cast<arangodb::aql::RegisterId>(curRegs),
|
||||||
|
AqlValue(doc));
|
||||||
|
}
|
||||||
// No harm done, if the setValue throws!
|
// No harm done, if the setValue throws!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,8 +231,7 @@ void arangodb::aql::removeRedundantSortsRule(Optimizer* opt,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_set<ExecutionNode*> toUnlink;
|
std::unordered_set<ExecutionNode*> toUnlink;
|
||||||
|
arangodb::basics::StringBuffer buffer(TRI_UNKNOWN_MEM_ZONE, false);
|
||||||
arangodb::basics::StringBuffer buffer(TRI_UNKNOWN_MEM_ZONE);
|
|
||||||
|
|
||||||
for (auto const& n : nodes) {
|
for (auto const& n : nodes) {
|
||||||
if (toUnlink.find(n) != toUnlink.end()) {
|
if (toUnlink.find(n) != toUnlink.end()) {
|
||||||
|
@ -1367,7 +1366,7 @@ void arangodb::aql::removeRedundantCalculationsRule(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
arangodb::basics::StringBuffer buffer(TRI_UNKNOWN_MEM_ZONE);
|
arangodb::basics::StringBuffer buffer(TRI_UNKNOWN_MEM_ZONE, false);
|
||||||
std::unordered_map<VariableId, Variable const*> replacements;
|
std::unordered_map<VariableId, Variable const*> replacements;
|
||||||
|
|
||||||
for (auto const& n : nodes) {
|
for (auto const& n : nodes) {
|
||||||
|
|
Loading…
Reference in New Issue