summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@oath.com>2018-04-19 12:10:04 +0000
committerGeir Storli <geirst@oath.com>2018-04-19 12:12:22 +0000
commit9b9eed604e6684c015e9bfd666cd226d969e0b18 (patch)
tree156215d06eea6aea034343dd837ab3100434db1a /searchlib
parent33ef61f554a5768c4457e78207c689fbf5661220 (diff)
Assert that attribute can be down-casted to tensor attribute.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp
index 9ea598d3578..4f355255db5 100644
--- a/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp
@@ -7,11 +7,23 @@ namespace search::tensor {
using vespalib::tensor::Tensor;
+namespace {
+
+const ITensorAttribute &
+getTensorAttribute(const search::attribute::IAttributeVector &attr)
+{
+ const ITensorAttribute *result = attr.asTensorAttribute();
+ assert(result != nullptr);
+ return *result;
+}
+
+}
+
ImportedTensorAttributeVectorReadGuard::ImportedTensorAttributeVectorReadGuard(const attribute::ImportedAttributeVector &imported_attribute,
bool stableEnumGuard)
: ImportedAttributeVectorReadGuard(imported_attribute,
stableEnumGuard),
- _target_tensor_attribute(*imported_attribute.getTargetAttribute()->asTensorAttribute())
+ _target_tensor_attribute(getTensorAttribute(*imported_attribute.getTargetAttribute()))
{
}