aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-12-22 12:47:31 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-12-22 12:47:31 +0000
commit6eaf499cb147f2c12a73a466a0dcb7a0f7a35fef (patch)
tree99838515421daf20f64dbae0e2327195855bb84f /eval
parent339bb769446c7f3fd9812b71a6040ca774dfec82 (diff)
handle unsupported cell types more gracefully
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/eval/cell_type.h4
-rw-r--r--eval/src/vespa/eval/eval/fast_value.hpp11
2 files changed, 10 insertions, 5 deletions
diff --git a/eval/src/vespa/eval/eval/cell_type.h b/eval/src/vespa/eval/eval/cell_type.h
index 2d21e72182f..a371e618f37 100644
--- a/eval/src/vespa/eval/eval/cell_type.h
+++ b/eval/src/vespa/eval/eval/cell_type.h
@@ -20,10 +20,6 @@ template <> constexpr CellType get_cell_type<float>() { return CellType::FLOAT;
template <> constexpr CellType get_cell_type<BFloat16>() { return CellType::BFLOAT16; }
template <> constexpr CellType get_cell_type<Int8Float>() { return CellType::INT8; }
-// NOTE: this was added in order to allow using FastValue that is
-// templated on values that are not supported cell types.
-template <typename CT> constexpr CellType get_cell_type() { abort(); }
-
// check if the given CellType enum value and actual cell type match
template <typename CT> constexpr bool check_cell_type(CellType type) {
return (type == get_cell_type<CT>());
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp
index 6cc2c12d9ec..991e96c5143 100644
--- a/eval/src/vespa/eval/eval/fast_value.hpp
+++ b/eval/src/vespa/eval/eval/fast_value.hpp
@@ -234,7 +234,16 @@ struct FastValue final : Value, ValueBuilder<T> {
~FastValue() override;
const ValueType &type() const override { return my_type; }
const Value::Index &index() const override { return my_index; }
- TypedCells cells() const override { return TypedCells(my_cells.memory, get_cell_type<T>(), my_cells.size); }
+ TypedCells cells() const override {
+ if constexpr (std::is_same_v<T, uint32_t>) {
+ // allow use of FastValue templated on types that do not
+ // have a corresponding cell type as long as cells() is
+ // not called
+ abort();
+ } else {
+ return TypedCells(my_cells.memory, get_cell_type<T>(), my_cells.size);
+ }
+ }
void add_mapping(ConstArrayRef<vespalib::stringref> addr) {
if constexpr (transient) {
(void) addr;