aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/number_or_object.h
blob: 3c15058092efae1146ccb9efd5b31fb289e77726 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/common/feature.h>
#include <vespa/eval/eval/value.h>

namespace search::fef {

/**
 * Storage cell for values passed between feature executors in the
 * ranking framework. The union either contains a double value
 * directly (number) or a reference to a polymorphic value stored
 * elsewhere (object).
 **/
union NumberOrObject {
    feature_t                   as_number;
    vespalib::eval::Value::CREF as_object;
    char                        as_bytes[std::max(sizeof(as_number), sizeof(as_object))];
    NumberOrObject() { memset(as_bytes, 0, sizeof(as_bytes)); }
    ~NumberOrObject() {}
};

}