blob: 79c636f93dfa98fcb92c8f7676af0e4356bca4f9 (
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
|
// 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 <memory>
namespace search::fef {
/**
* The full type of a feature calculated by the ranking framework. The
* ranking framework wraps a thin layer on top of the types defined in
* the low-level eval library. A feature can either be a simple number
* represented by a double or a polymorph value represented with an
* object. The ranking framework itself will mostly care about the
* representation (number/object) and not the specific type. The type
* function is used to extract the underlying type and is only allowed
* for features that are objects.
**/
class FeatureType {
private:
using TYPE = vespalib::eval::ValueType;
using TYPE_UP = std::unique_ptr<TYPE>;
TYPE_UP _type;
static const FeatureType _number;
explicit FeatureType(TYPE_UP type_in) : _type(std::move(type_in)) {}
public:
FeatureType(const FeatureType &rhs);
FeatureType(FeatureType &&rhs) noexcept = default;
[[nodiscard]] bool is_object() const { return (_type.get() != nullptr); }
[[nodiscard]] const TYPE &type() const;
static const FeatureType &number() { return _number; }
static FeatureType object(const TYPE &type_in);
};
}
|