diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-12-04 12:51:48 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-12-06 20:59:45 +0100 |
commit | 6ecf2793233d3fa44fa6316e27be2220dce883ab (patch) | |
tree | efef97643cbc9aeb503bf4109a27e480794d4ddd | |
parent | 275fe933a20d6f0c1c9bb54a895b577c2a9fe10a (diff) |
add utility for wrapping cells vector as dense value
-rw-r--r-- | eval/src/vespa/eval/eval/CMakeLists.txt | 1 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/dense_cells_value.cpp | 12 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/dense_cells_value.h | 28 |
3 files changed, 41 insertions, 0 deletions
diff --git a/eval/src/vespa/eval/eval/CMakeLists.txt b/eval/src/vespa/eval/eval/CMakeLists.txt index d32841520a6..57c0db1719b 100644 --- a/eval/src/vespa/eval/eval/CMakeLists.txt +++ b/eval/src/vespa/eval/eval/CMakeLists.txt @@ -8,6 +8,7 @@ vespa_add_library(eval_eval OBJECT cell_type.cpp compile_tensor_function.cpp delete_node.cpp + dense_cells_value.cpp double_value_builder.cpp fast_forest.cpp fast_sparse_map.cpp diff --git a/eval/src/vespa/eval/eval/dense_cells_value.cpp b/eval/src/vespa/eval/eval/dense_cells_value.cpp new file mode 100644 index 00000000000..15de4dc0b26 --- /dev/null +++ b/eval/src/vespa/eval/eval/dense_cells_value.cpp @@ -0,0 +1,12 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "dense_cells_value.h" + +namespace vespalib::eval { + +template<typename T> DenseCellsValue<T>::~DenseCellsValue() = default; + +template class DenseCellsValue<double>; +template class DenseCellsValue<float>; + +} diff --git a/eval/src/vespa/eval/eval/dense_cells_value.h b/eval/src/vespa/eval/eval/dense_cells_value.h new file mode 100644 index 00000000000..021203ec78a --- /dev/null +++ b/eval/src/vespa/eval/eval/dense_cells_value.h @@ -0,0 +1,28 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <vespa/eval/eval/value.h> + +namespace vespalib::eval { + +/** + * A dense-only value that just owns a vector of cells. + **/ +template<typename T> +class DenseCellsValue : public Value { +private: + const ValueType &_type; + std::vector<T> _cells; +public: + DenseCellsValue(const ValueType &type_ref, std::vector<T> cells) + : _type(type_ref), _cells(std::move(cells)) + {} + const ValueType &type() const override { return _type; } + TypedCells cells() const override { return TypedCells(_cells); } + const Index &index() const override { return TrivialIndex::get(); } + MemoryUsage get_memory_usage() const override { + return self_memory_usage<DenseCellsValue<T>>(); + } + ~DenseCellsValue(); +}; + +} |