diff options
author | Geir Storli <geirst@oath.com> | 2018-04-19 12:10:04 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-04-19 12:12:22 +0000 |
commit | 9b9eed604e6684c015e9bfd666cd226d969e0b18 (patch) | |
tree | 156215d06eea6aea034343dd837ab3100434db1a | |
parent | 33ef61f554a5768c4457e78207c689fbf5661220 (diff) |
Assert that attribute can be down-casted to tensor attribute.
-rw-r--r-- | searchlib/src/vespa/searchlib/tensor/imported_tensor_attribute_vector_read_guard.cpp | 14 | ||||
-rw-r--r-- | searchsummary/src/vespa/searchsummary/docsummary/attributedfw.cpp | 1 |
2 files changed, 14 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())) { } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/attributedfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/attributedfw.cpp index 5e8e4ee0584..2feca5fc0c7 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/attributedfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/attributedfw.cpp @@ -137,6 +137,7 @@ SingleAttrDFW::insertField(uint32_t docid, switch (t) { case BasicType::TENSOR: { const tensor::ITensorAttribute *tv = v.asTensorAttribute(); + assert(tv != nullptr); const auto tensor = tv->getTensor(docid); if (tensor) { vespalib::nbostream str; |