summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-04-13 10:00:43 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-04-13 10:00:43 +0000
commit8ce8effad4cb248b4f37fdbf04bb3d88259dc651 (patch)
treed66e4d5b4a96fd78fd53ac81b97db10f6cf975b2
parent604b0cf0149a73dadffc219b1a70fabbf8ce26ad (diff)
If there is a enum reference to the empty string (default value), it must be used.
-rw-r--r--searchlib/src/vespa/searchlib/attribute/stringbase.h2
-rw-r--r--searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp15
2 files changed, 8 insertions, 9 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.h b/searchlib/src/vespa/searchlib/attribute/stringbase.h
index ed8777d6bab..5c6bf3c6b6a 100644
--- a/searchlib/src/vespa/searchlib/attribute/stringbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/stringbase.h
@@ -53,11 +53,11 @@ public:
largeint_t getInt(DocId doc) const override { return strtoll(get(doc), nullptr, 0); }
double getFloat(DocId doc) const override;
vespalib::ConstArrayRef<char> get_raw(DocId) const override;
+ static const char * defaultValue() { return ""; }
protected:
StringAttribute(const vespalib::string & name);
StringAttribute(const vespalib::string & name, const Config & c);
~StringAttribute() override;
- static const char * defaultValue() { return ""; }
using Change = ChangeTemplate<StringChangeData>;
using ChangeVector = ChangeVectorT<Change>;
using EnumEntryType = const char*;
diff --git a/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp b/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp
index b3cc126efdb..df3b4f06eb7 100644
--- a/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp
+++ b/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attribute_map_lookup_node.h"
-#include <vespa/vespalib/stllike/asciistream.h>
-#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/searchlib/attribute/stringbase.h>
#include <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchcommon/attribute/iattributecontext.h>
-#include <vespa/searchcommon/common/undefinedvalues.h>
+#include <vespa/vespalib/stllike/asciistream.h>
+#include <vespa/vespalib/util/exceptions.h>
using search::attribute::AttributeContent;
using search::attribute::IAttributeVector;
@@ -36,8 +36,6 @@ public:
namespace {
-vespalib::string indirectKeyMarker("attribute(");
-
class BadKeyHandler : public AttributeMapLookupNode::KeyHandler
{
public:
@@ -220,7 +218,6 @@ IAttributeVector::largeint_t getUndefinedValue(BasicType::Type basicType)
return getUndefined<int32_t>();
case BasicType::INT64:
return getUndefined<int64_t>();
- break;
default:
return 0;
}
@@ -330,7 +327,6 @@ AttributeMapLookupNode::onPrepare(bool preserveAccurateTypes)
break;
default:
throw std::runtime_error("This is no valid integer attribute " + attribute->getName());
- break;
}
} else {
prepareIntValues<Int64ResultNode>(std::move(keyHandler), *attribute, undefinedValue);
@@ -342,7 +338,10 @@ AttributeMapLookupNode::onPrepare(bool preserveAccurateTypes)
} else if (attribute->isStringType()) {
if (_useEnumOptimization) {
auto resultNode = std::make_unique<EnumResultNode>();
- _handler = std::make_unique<EnumValueHandler>(std::move(keyHandler), *attribute, *resultNode, EnumHandle());
+ const StringAttribute & sattr = dynamic_cast<const StringAttribute &>(*attribute);
+ EnumHandle undefined(0);
+ attribute->findEnum(sattr.defaultValue(), undefined);
+ _handler = std::make_unique<EnumValueHandler>(std::move(keyHandler), *attribute, *resultNode, undefined);
setResultType(std::move(resultNode));
} else {
auto resultNode = std::make_unique<StringResultNode>();