aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-11-03 19:37:45 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-11-04 15:41:42 +0000
commit0d0cac5fcb486de12275fb99f44b0b1ae8e89d39 (patch)
treee561c53ded0f059320055ef59afaf9236c744b2a
parent331fe56f5a290d0377c9dcddfc83467486dd8067 (diff)
Use explicit singlevalue interface.
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp b/searchcore/src/vespa/searchcore/proton/common/attributefieldvaluenode.cpp
index 94473c10d3c..25113f3b65f 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 <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchlib/attribute/attributevector.h>
+#include <vespa/searchlib/attribute/stringbase.h>
#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/vespalib/util/exceptions.h>
#include <cassert>
@@ -40,24 +41,23 @@ AttributeFieldValueNode(const vespalib::string& doctype,
std::unique_ptr<document::select::Value>
-AttributeFieldValueNode::
-getValue(const Context &context) const
+AttributeFieldValueNode::getValue(const Context &context) const
{
const auto &sc(static_cast<const SelectContext &>(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<NullValue>();
- }
switch (v.getBasicType()) {
case BasicType::STRING:
{
- AttributeContent<const char *> content;
- content.fill(v, docId);
- assert(content.size() == 1u);
- return std::make_unique<StringValue>(content[0]);
- };
+ const auto & s = static_cast<const search::StringAttribute &>(v);
+ const char * value = s.get(docId);
+ if (search::attribute::isUndefined(value)) {
+ return std::make_unique<NullValue>();
+ } else {
+ return std::make_unique<StringValue>(value);
+ }
+ }
case BasicType::BOOL:
case BasicType::UINT2:
case BasicType::UINT4:
@@ -66,6 +66,9 @@ getValue(const Context &context) const
case BasicType::INT32:
case BasicType::INT64:
{
+ if (v.isUndefined(docId)) {
+ return std::make_unique<NullValue>();
+ }
AttributeContent<IAttributeVector::largeint_t> content;
content.fill(v, docId);
assert(content.size() == 1u);
@@ -74,11 +77,14 @@ getValue(const Context &context) const
case BasicType::FLOAT:
case BasicType::DOUBLE:
{
+ if (v.isUndefined(docId)) {
+ return std::make_unique<NullValue>();
+ }
AttributeContent<double> content;
content.fill(v, docId);
assert(content.size() == 1u);
return std::make_unique<FloatValue>(content[0]);
- };
+ }
case BasicType::NONE:
case BasicType::PREDICATE:
case BasicType::TENSOR:
@@ -89,7 +95,7 @@ getValue(const Context &context) const
case BasicType::MAX_TYPE:
throw IllegalStateException(make_string("Attribute '%s' has illegal type '%d'", v.getName().c_str(), v.getBasicType()));
}
- return std::make_unique<NullValue>();;
+ return std::make_unique<NullValue>();
}