Use memory from EvaluationContext in awesome functions
Reviewers: mferencevic, msantl, mtomic Reviewed By: msantl Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2133
This commit is contained in:
parent
3fd14e2d5f
commit
65ab2574bc
File diff suppressed because it is too large
Load Diff
@ -381,22 +381,23 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
for (size_t i = 0; i < function.arguments_.size(); ++i) {
|
||||
arguments[i] = function.arguments_[i]->Accept(*this);
|
||||
}
|
||||
// TODO: Update awesome_memgraph_functions to use the allocator from ctx_
|
||||
return TypedValue(function.function_(
|
||||
arguments, function.arguments_.size(), *ctx_, dba_),
|
||||
ctx_->memory);
|
||||
auto res = function.function_(arguments, function.arguments_.size(),
|
||||
*ctx_, dba_);
|
||||
CHECK(res.GetMemoryResource() == ctx_->memory);
|
||||
return res;
|
||||
} else {
|
||||
TypedValue::TVector arguments(ctx_->memory);
|
||||
arguments.reserve(function.arguments_.size());
|
||||
for (const auto &argument : function.arguments_) {
|
||||
arguments.emplace_back(argument->Accept(*this));
|
||||
}
|
||||
// TODO: Update awesome_memgraph_functions to use the allocator from ctx_
|
||||
return TypedValue(
|
||||
function.function_(arguments.data(), arguments.size(), *ctx_, dba_),
|
||||
ctx_->memory);
|
||||
auto res =
|
||||
function.function_(arguments.data(), arguments.size(), *ctx_, dba_);
|
||||
CHECK(res.GetMemoryResource() == ctx_->memory);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
TypedValue Visit(Reduce &reduce) override {
|
||||
auto list_value = reduce.list_->Accept(*this);
|
||||
if (list_value.IsNull()) {
|
||||
|
@ -175,7 +175,7 @@ template <class TAllocator>
|
||||
std::basic_string<char, std::char_traits<char>, TAllocator> *Replace(
|
||||
std::basic_string<char, std::char_traits<char>, TAllocator> *out,
|
||||
const std::string_view &src, const std::string_view &match,
|
||||
const std::string_view &replacement, const TAllocator &alloc) {
|
||||
const std::string_view &replacement) {
|
||||
// TODO: This could be implemented much more efficiently.
|
||||
*out = src;
|
||||
for (size_t pos = out->find(match); pos != std::string::npos;
|
||||
@ -190,7 +190,7 @@ inline std::string Replace(const std::string_view &src,
|
||||
const std::string_view &match,
|
||||
const std::string_view &replacement) {
|
||||
std::string res;
|
||||
Replace(&res, src, match, replacement, std::allocator<char>());
|
||||
Replace(&res, src, match, replacement);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user