Add FunctionContext to simplify awesome function signature

Reviewers: ipaljak, mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2327
This commit is contained in:
Teon Banek
2019-08-26 15:50:26 +02:00
parent 023538c19c
commit a878a11e70
4 changed files with 123 additions and 127 deletions

View File

@@ -371,6 +371,8 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
}
TypedValue Visit(Function &function) override {
FunctionContext function_ctx{dba_, ctx_->memory, ctx_->timestamp,
&ctx_->counters};
// Stack allocate evaluated arguments when there's a small number of them.
if (function.arguments_.size() <= 8) {
TypedValue arguments[8] = {
@@ -382,7 +384,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
arguments[i] = function.arguments_[i]->Accept(*this);
}
auto res = function.function_(arguments, function.arguments_.size(),
*ctx_, dba_);
function_ctx);
CHECK(res.GetMemoryResource() == ctx_->memory);
return res;
} else {
@@ -392,7 +394,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
arguments.emplace_back(argument->Accept(*this));
}
auto res =
function.function_(arguments.data(), arguments.size(), *ctx_, dba_);
function.function_(arguments.data(), arguments.size(), function_ctx);
CHECK(res.GetMemoryResource() == ctx_->memory);
return res;
}