diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-04-01 20:12:32 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-04-02 10:01:37 +0000 |
commit | 6f4adccc7e373b3539441c985ae9499b87148e95 (patch) | |
tree | d6db21a3ad438c7997cb9ef05507b8c4644f2913 /eval | |
parent | 8646f3bbaf0dd3127c26892efcd7b873edc8712d (diff) |
Add cell_type
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/value_type.cpp | 4 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/value_type.h | 17 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/value_type_spec.cpp | 8 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/value_type_spec.h | 8 |
4 files changed, 18 insertions, 19 deletions
diff --git a/eval/src/vespa/eval/eval/value_type.cpp b/eval/src/vespa/eval/eval/value_type.cpp index 1d49fe494b7..4d74d0b0e54 100644 --- a/eval/src/vespa/eval/eval/value_type.cpp +++ b/eval/src/vespa/eval/eval/value_type.cpp @@ -199,13 +199,13 @@ ValueType::rename(const std::vector<vespalib::string> &from, } ValueType -ValueType::tensor_type(std::vector<Dimension> dimensions_in) +ValueType::tensor_type(CellType cellType, std::vector<Dimension> dimensions_in) { sort_dimensions(dimensions_in); if (has_duplicates(dimensions_in)) { return error_type(); } - return ValueType(Type::TENSOR, std::move(dimensions_in)); + return ValueType(Type::TENSOR, cellType, std::move(dimensions_in)); } ValueType diff --git a/eval/src/vespa/eval/eval/value_type.h b/eval/src/vespa/eval/eval/value_type.h index 564d6a6b84e..f08bd57ac11 100644 --- a/eval/src/vespa/eval/eval/value_type.h +++ b/eval/src/vespa/eval/eval/value_type.h @@ -4,7 +4,6 @@ #include <vespa/vespalib/stllike/string.h> #include <vector> -#include <memory> namespace vespalib::eval { @@ -17,6 +16,7 @@ class ValueType { public: enum class Type { ANY, ERROR, DOUBLE, TENSOR }; + enum class CellType {FLOAT, DOUBLE}; struct Dimension { using size_type = uint32_t; static constexpr size_type npos = -1; @@ -36,13 +36,18 @@ public: }; private: - Type _type; + Type _type; + CellType _cellType; std::vector<Dimension> _dimensions; explicit ValueType(Type type_in) - : _type(type_in), _dimensions() {} + : ValueType(type_in, CellType::DOUBLE) {} + ValueType(Type type_in, CellType cellType) + : _type(type_in), _cellType(cellType), _dimensions() {} ValueType(Type type_in, std::vector<Dimension> &&dimensions_in) - : _type(type_in), _dimensions(std::move(dimensions_in)) {} + : ValueType(type_in, CellType::DOUBLE, std::move(dimensions_in)) {} + ValueType(Type type_in, CellType cellType, std::vector<Dimension> &&dimensions_in) + : _type(type_in), _cellType(cellType), _dimensions(std::move(dimensions_in)) {} public: ValueType(ValueType &&) = default; @@ -51,6 +56,7 @@ public: ValueType &operator=(const ValueType &) = default; ~ValueType(); Type type() const { return _type; } + CellType cell_type() const { return _cellType; } bool is_any() const { return (_type == Type::ANY); } bool is_error() const { return (_type == Type::ERROR); } bool is_double() const { return (_type == Type::DOUBLE); } @@ -82,7 +88,8 @@ public: static ValueType any_type() { return ValueType(Type::ANY); } static ValueType error_type() { return ValueType(Type::ERROR); }; static ValueType double_type() { return ValueType(Type::DOUBLE); } - static ValueType tensor_type(std::vector<Dimension> dimensions_in); + static ValueType tensor_type(std::vector<Dimension> dimensions_in) { return tensor_type(CellType::DOUBLE, dimensions_in); } + static ValueType tensor_type(CellType cellType, std::vector<Dimension> dimensions_in); static ValueType from_spec(const vespalib::string &spec); vespalib::string to_spec() const; static ValueType join(const ValueType &lhs, const ValueType &rhs); diff --git a/eval/src/vespa/eval/eval/value_type_spec.cpp b/eval/src/vespa/eval/eval/value_type_spec.cpp index cf0fb6d493a..229a9201f08 100644 --- a/eval/src/vespa/eval/eval/value_type_spec.cpp +++ b/eval/src/vespa/eval/eval/value_type_spec.cpp @@ -6,9 +6,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <algorithm> -namespace vespalib { -namespace eval { -namespace value_type { +namespace vespalib::eval::value_type { namespace { @@ -205,6 +203,4 @@ to_spec(const ValueType &type) return os.str(); } -} // namespace vespalib::eval::value_type -} // namespace vespalib::eval -} // namespace vespalib +} diff --git a/eval/src/vespa/eval/eval/value_type_spec.h b/eval/src/vespa/eval/eval/value_type_spec.h index 76d50834ae8..f2609f59f32 100644 --- a/eval/src/vespa/eval/eval/value_type_spec.h +++ b/eval/src/vespa/eval/eval/value_type_spec.h @@ -4,15 +4,11 @@ #include "value_type.h" -namespace vespalib { -namespace eval { -namespace value_type { +namespace vespalib::eval::value_type { ValueType parse_spec(const char *pos_in, const char *end_in, const char *&pos_out); ValueType from_spec(const vespalib::string &str); vespalib::string to_spec(const ValueType &type); -} // namespace vespalib::eval::value_type -} // namespace vespalib::eval -} // namespace vespalib +} |