<commit_before>// Copyright 2018 <NAME>. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/testkit/test_kit.h>
#include "eval_fixture.h"
#include <vespa/eval/eval/make_tensor_function.h>

namespace vespalib::eval::test {

using ParamRepo = EvalFixture::ParamRepo;

namespace {

std::shared_ptr<Function const> verify_function(std::shared_ptr<Function const> fun) {
    if (fun->has_error()) {
        fprintf(stderr, "eval_fixture: function parse failed: %s\n", fun->get_error().c_str());
    }
    ASSERT_TRUE(!fun->has_error());
    return std::move(fun);
}

NodeTypes get_types(const Function &function, const ParamRepo &param_repo) {
    std::vector<ValueType> param_types;
    for (size_t i = 0; i < function.num_params(); ++i) {
        auto pos = param_repo.map.find(function.param_name(i));
        ASSERT_TRUE(pos != param_repo.map.end());
        param_types.push_back(ValueType::from_spec(pos->second.value.type()));
        ASSERT_TRUE(!param_types.back().is_error());
    }
    return NodeTypes(function, param_types);
}

std::set<size_t> get_mutable(const Function &function, const ParamRepo &param_repo) {
    std::set<size_t> mutable_set;
    for (size_t i = 0; i < function.num_params(); ++i) {
        auto pos = param_repo.map.find(function.param_name(i));
        ASSERT_TRUE(pos != param_repo.map.end());
        if (pos->second.is_mutable) {
            mutable_set.insert(i);
        }
    }
    return mutable_set;
}

struct MyMutableInject : public tensor_function::Inject {
    MyMutableInject(const ValueType &result_type_in, size_t param_idx_in)<commit_msg>Eliminate redundant move in return statement.<commit_after>// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/testkit/test_kit.h>
#include "eval_fixture.h"
#include <vespa/eval/eval/make_tensor_function.h>

namespace vespalib::eval::test {

using ParamRepo = EvalFixture::ParamRepo;

namespace {

std::shared_ptr<Function const> verify_function(std::shared_ptr<Function const> fun) {
    if (fun->has_error()) {
        fprintf(stderr, "eval_fixture: function parse failed: %s\n", fun->get_error().c_str());
    }
    ASSERT_TRUE(!fun->has_error());
    return fun;
}

NodeTypes get_types(const Function &function, const ParamRepo &param_repo) {
    std::vector<ValueType> param_types;
    for (size_t i = 0; i < function.num_params(); ++i) {
        auto pos = param_repo.map.find(function.param_name(i));
        ASSERT_TRUE(pos != param_repo.map.end());
        param_types.push_back(ValueType::from_spec(pos->second.value.type()));
        ASSERT_TRUE(!param_types.back().is_error());
    }
    return NodeTypes(function, param_types);
}

std::set<size_t> get_mutable(const Function &function, const ParamRepo &param_repo) {
    std::set<size_t> mutable_set;
    for (size_t i = 0; i < function.num_params(); ++i) {
        auto pos = param_repo.map.find(function.param_name(i));
        ASSERT_TRUE(pos != param_repo.map.end());
        if (pos->second.is_mutable) {
            mutable_set.insert(i);
        }
    }
    return mutable_set;
}

struct MyMutableInject : public tensor_function::Inject {
    MyMutableInject(const ValueType &result_type_in, size_t param_idx_in)
{'fraction_non_alphanumeric': 0.13580246913580246, 'fraction_numerical': 0.004817825956037338, 'mean_word_length': 4.1265432098765435, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2132016', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1112, 'n_words': 223}