aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/expression/arrayoperationnode.cpp
blob: f9182f8fcc23012c89a262ed83330d657720cb57 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "arrayoperationnode.h"
#include <vespa/vespalib/util/stringfmt.h>

namespace search {
namespace expression {

IMPLEMENT_ABSTRACT_EXPRESSIONNODE(ArrayOperationNode, FunctionNode);

ArrayOperationNode::ArrayOperationNode()
  : FunctionNode(), _attributeName(), _attribute(0), _docId(0)
{}

ArrayOperationNode::ArrayOperationNode(const ArrayOperationNode& rhs)
  : FunctionNode(),
    _attributeName(rhs._attributeName),
    _attribute(rhs._attribute),
    _docId(0)
{}

// for unit testing
ArrayOperationNode::ArrayOperationNode(IAttributeVector &attr)
  : FunctionNode(),
    _attributeName(attr.getName()),
    _attribute(&attr),
    _docId(0)
{}

ArrayOperationNode&
ArrayOperationNode::operator= (const ArrayOperationNode& rhs)
{
        _attributeName = rhs._attributeName;
        _attribute = rhs._attribute;
        _docId = 0;
        return *this;
}

void
ArrayOperationNode::wireAttributes(const IAttributeContext &attrCtx)
{
    _attribute = attrCtx.getAttribute(_attributeName);
    if (_attribute == NULL) {
        throw std::runtime_error(vespalib::make_string("Failed locating attribute vector '%s'", _attributeName.c_str()));
    }
}

using vespalib::Serializer;
using vespalib::Deserializer;

Serializer & ArrayOperationNode::onSerialize(Serializer & os) const
{
    FunctionNode::onSerialize(os);
    os << _attributeName;
    return os;
}

Deserializer & ArrayOperationNode::onDeserialize(Deserializer & is)
{
    FunctionNode::onDeserialize(is);
    is >> _attributeName;
    return is;
}

} // namespace expression
} // namespace search