aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/features/tensor_attribute_executor.cpp
blob: b78b194d0ef1f6cb8dbaed5665f5ee9c142f5de2 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "tensor_attribute_executor.h"
#include <vespa/searchlib/tensor/i_tensor_attribute.h>

namespace search::features {

TensorAttributeExecutor::
TensorAttributeExecutor(const search::tensor::ITensorAttribute& attribute)
    : _attribute(attribute),
      _emptyTensor(attribute.getEmptyTensor()),
      _tensor()
{
}

void
TensorAttributeExecutor::execute(uint32_t docId)
{
    _tensor = _attribute.getTensor(docId);
    if (_tensor) {
        outputs().set_object(0, *_tensor);
    } else {
        outputs().set_object(0, *_emptyTensor);
    }
}

}