diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-12 13:36:51 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-12 13:43:01 +0000 |
commit | 1484bcea42fb6d8ffe308805a5782b0f0f2265ed (patch) | |
tree | 1c3dd4dd03086fe435f78a75f2ba281931674854 /searchlib | |
parent | 6038db2a9afc0f9395a748fe13b9ed7293840d8a (diff) |
Move from protected to private section.
Diffstat (limited to 'searchlib')
3 files changed, 19 insertions, 15 deletions
diff --git a/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp b/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp index 757f74bdaff..8ddf5ea63f7 100644 --- a/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp +++ b/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp @@ -234,9 +234,7 @@ Fixture::makeNode(const vespalib::string &attributeName, bool useEnumOptimizatio } else { node = makeAttributeMapLookupNode(attributeName); } - if (useEnumOptimization) { - node->useEnumOptimization(); - } + node->enableEnumOptimization(useEnumOptimization); AttributeNode::Configure configure(context); node->select(configure, configure); node->prepare(preserveAccurateTypes); 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 f9f93bc8661..54dc9bfaa02 100644 --- a/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp +++ b/searchlib/src/vespa/searchlib/expression/attribute_map_lookup_node.cpp @@ -271,7 +271,7 @@ AttributeMapLookupNode::makeKeyHandlerHelper() const return std::make_unique<BadKeyHandler>(attribute); } } - if (attribute.hasEnum() && _useEnumOptimization) { + if (attribute.hasEnum() && useEnumOptimization()) { return std::make_unique<EnumKeyHandler>(attribute, _key); } else if (attribute.isIntegerType()) { return std::make_unique<IntegerKeyHandler>(attribute, _key); @@ -321,7 +321,7 @@ AttributeMapLookupNode::createResultHandler(bool preserveAccurateTypes, const at auto handler = std::make_unique<FloatValueHandler>(std::move(keyHandler), attribute, *resultNode, getUndefined<double>()); return { std::move(resultNode), std::move(handler) }; } else if (attribute.isStringType()) { - if (_useEnumOptimization) { + if (useEnumOptimization()) { auto resultNode = std::make_unique<EnumResultNode>(); const StringAttribute & sattr = dynamic_cast<const StringAttribute &>(attribute); EnumHandle undefined(0); @@ -351,10 +351,10 @@ AttributeMapLookupNode::cleanup() void AttributeMapLookupNode::wireAttributes(const search::attribute::IAttributeContext &attrCtx) { - auto valueAttribute = findAttribute(attrCtx, _useEnumOptimization, _valueAttributeName); - _hasMultiValue = false; - _scratchResult = std::make_unique<AttributeResult>(valueAttribute, 0); - _keyAttribute = findAttribute(attrCtx, _useEnumOptimization, _keyAttributeName); + auto valueAttribute = findAttribute(attrCtx, useEnumOptimization(), _valueAttributeName); + setHasMultiValue(false); + setScratchResult(std::make_unique<AttributeResult>(valueAttribute, 0)); + _keyAttribute = findAttribute(attrCtx, useEnumOptimization(), _keyAttributeName); if (!_keySourceAttributeName.empty()) { _keySourceAttribute = findAttribute(attrCtx, false, _keySourceAttributeName); } diff --git a/searchlib/src/vespa/searchlib/expression/attributenode.h b/searchlib/src/vespa/searchlib/expression/attributenode.h index 2a677889597..781861aa958 100644 --- a/searchlib/src/vespa/searchlib/expression/attributenode.h +++ b/searchlib/src/vespa/searchlib/expression/attributenode.h @@ -52,10 +52,9 @@ public: const attribute::IAttributeVector *getAttribute() const { return _scratchResult ? _scratchResult->getAttribute() : nullptr; } - const vespalib::string & getAttributeName() const { return _attributeName; } + const vespalib::string & getAttributeName() const noexcept { return _attributeName; } - void useEnumOptimization(bool use=true) { _useEnumOptimization = use; } - bool hasMultiValue() const { return _hasMultiValue; } + void enableEnumOptimization(bool enable) noexcept { _useEnumOptimization = enable; } public: class Handler { @@ -70,11 +69,8 @@ private: class FloatHandler; class StringHandler; class EnumHandler; -protected: - virtual void cleanup(); void wireAttributes(const attribute::IAttributeContext & attrCtx) override; void onPrepare(bool preserveAccurateTypes) override; - bool onExecute() const override; std::unique_ptr<AttributeResult> _scratchResult; const CurrentIndex *_index; @@ -83,6 +79,16 @@ protected: bool _useEnumOptimization; mutable bool _needExecute; std::unique_ptr<Handler> _handler; +protected: + void setHasMultiValue(bool has) noexcept { _hasMultiValue = has; } + [[nodiscard]] bool useEnumOptimization() const noexcept { return _useEnumOptimization; } + [[nodiscard]] bool hasMultiValue() const noexcept { return _hasMultiValue; } + + void setScratchResult(std::unique_ptr<AttributeResult> result) noexcept { + _scratchResult = std::move(result); + } + virtual void cleanup(); + bool onExecute() const override; vespalib::string _attributeName; }; |