From 22b5d4a3e694200e968b020ec935d5a983aae7d0 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 6 Nov 2023 13:16:47 +0000 Subject: Not possible to do safe cast here. Must leav as is and wait until we clean up with proper get interfaces. --- .../proton/common/attributefieldvaluenode.cpp | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp index 6e1177d9065..d94b0a4c909 100644 --- a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp @@ -4,7 +4,6 @@ #include "selectcontext.h" #include #include -#include #include #include #include @@ -38,22 +37,23 @@ AttributeFieldValueNode(const vespalib::string& doctype, std::unique_ptr -AttributeFieldValueNode::getValue(const Context &context) const +AttributeFieldValueNode:: +getValue(const Context &context) const { const auto &sc(static_cast(context)); uint32_t docId(sc._docId); assert(docId != 0u); const auto& v = sc.guarded_attribute_at_index(_attr_guard_index); + if (v.isUndefined(docId)) { + return std::make_unique(); + } switch (v.getBasicType()) { case BasicType::STRING: { - const auto & s = static_cast(v); - const char * value = s.get(docId); - if (search::attribute::isUndefined(value)) { - return std::make_unique(); - } else { - return std::make_unique(value); - } + AttributeContent content; + content.fill(v, docId); + assert(content.size() == 1u); + return std::make_unique(content[0]); } case BasicType::BOOL: case BasicType::UINT2: @@ -63,9 +63,6 @@ AttributeFieldValueNode::getValue(const Context &context) const case BasicType::INT32: case BasicType::INT64: { - if (v.isUndefined(docId)) { - return std::make_unique(); - } AttributeContent content; content.fill(v, docId); assert(content.size() == 1u); @@ -74,9 +71,6 @@ AttributeFieldValueNode::getValue(const Context &context) const case BasicType::FLOAT: case BasicType::DOUBLE: { - if (v.isUndefined(docId)) { - return std::make_unique(); - } AttributeContent content; content.fill(v, docId); assert(content.size() == 1u); -- cgit v1.2.3