aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/vespa/eval/instruction/join_with_number_function.h
blob: b26e626818a35de53746e1c86d8d600d491413bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/eval/eval/value_type.h>
#include <vespa/eval/eval/tensor_function.h>

namespace vespalib::eval {

/**
 * Tensor function for joining a general tensor with a number
 */
class JoinWithNumberFunction : public tensor_function::Op2
{
public:
    enum class Primary : uint8_t { LHS, RHS };
private:
    using Super = tensor_function::Op2;
    Primary _primary;
    tensor_function::join_fun_t _function;
public:

    JoinWithNumberFunction(const tensor_function::Join &original_join, bool number_on_left);
    ~JoinWithNumberFunction();
    Primary primary() const { return _primary; }
    bool primary_is_mutable() const;
    bool result_is_mutable() const override { return true; }

    InterpretedFunction::Instruction compile_self(const ValueBuilderFactory &factory, Stash &stash) const override;
    void visit_self(vespalib::ObjectVisitor &visitor) const override;
    static const TensorFunction &optimize(const TensorFunction &expr, Stash &stash);
};

} // namespace vespalib::eval