From f7678614029a004d4922551c88c4b19d87bde6bd Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 2 Jan 2020 10:44:33 +0000 Subject: Provide some more information --- .../proton/common/attributefieldvaluenode.cpp | 80 ++++++++++++---------- 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp index 21789364442..ab3b0588f3f 100644 --- a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp @@ -4,6 +4,7 @@ #include "selectcontext.h" #include #include +#include #include LOG_SETUP(".proton.common.attribute_field_value_node"); @@ -23,6 +24,9 @@ using search::attribute::AttributeContent; using search::attribute::BasicType; using search::attribute::CollectionType; using search::attribute::IAttributeVector; +using vespalib::IllegalArgumentException; +using vespalib::IllegalStateException; +using vespalib::make_string; AttributeFieldValueNode:: AttributeFieldValueNode(const vespalib::string& doctype, @@ -47,51 +51,53 @@ getValue(const Context &context) const assert(docId != 0u); const AttributeVector &v(*_attribute); if (v.isUndefined(docId)) { - return Value::UP(new NullValue); + return std::make_unique(); } switch (v.getBasicType()) { - case BasicType::STRING: - do { - AttributeContent content; - content.fill(v, docId); - assert(content.size() == 1u); - return Value::UP(new StringValue(content[0])); - } while (0); - break; - case BasicType::BOOL: - case BasicType::UINT2: - case BasicType::UINT4: - case BasicType::INT8: - case BasicType::INT16: - case BasicType::INT32: - case BasicType::INT64: - do { - AttributeContent content; - content.fill(v, docId); - assert(content.size() == 1u); - return Value::UP(new IntegerValue(content[0], false)); - } while (0); - break; - case BasicType::FLOAT: - case BasicType::DOUBLE: - do { - AttributeContent content; - content.fill(v, docId); - assert(content.size() == 1u); - return Value::UP(new FloatValue(content[0])); - } while (0); - break; - default: - LOG_ABORT("should not be reached"); + case BasicType::STRING: + { + AttributeContent content; + content.fill(v, docId); + assert(content.size() == 1u); + return std::make_unique(content[0]); + }; + case BasicType::BOOL: + case BasicType::UINT2: + case BasicType::UINT4: + case BasicType::INT8: + case BasicType::INT16: + case BasicType::INT32: + case BasicType::INT64: + { + AttributeContent content; + content.fill(v, docId); + assert(content.size() == 1u); + return std::make_unique(content[0], false); + } + case BasicType::FLOAT: + case BasicType::DOUBLE: + { + AttributeContent content; + content.fill(v, docId); + assert(content.size() == 1u); + return std::make_unique(content[0]); + }; + case BasicType::NONE: + case BasicType::PREDICATE: + case BasicType::TENSOR: + case BasicType::REFERENCE: + throw new IllegalArgumentException(make_string("Attribute '%s' of type '%s' can not be used for selection", + v.getName().c_str(), v.getInternalBasicType().asString())); + case BasicType::MAX_TYPE: + throw new IllegalStateException(make_string("Attribute '%s' has illegal type '%d'", v.getName().c_str(), v.getBasicType())); } - return Value::UP(); + return std::make_unique();; } std::unique_ptr -AttributeFieldValueNode::traceValue(const Context &context, - std::ostream& out) const +AttributeFieldValueNode::traceValue(const Context &context, std::ostream& out) const { return defaultTrace(getValue(context), out); } -- cgit v1.2.3