From 52bd8de700f4bcf6f2efc63c76aaff4317d9af3b Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 3 Jan 2020 12:18:54 +0000 Subject: predicate, tensor and reference attributes will not be tried fetched form attributes during selection. Fallback to fetch from document. --- .../searchcore/proton/common/cachedselect.cpp | 44 +++++++++++++--------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'searchcore') diff --git a/searchcore/src/vespa/searchcore/proton/common/cachedselect.cpp b/searchcore/src/vespa/searchcore/proton/common/cachedselect.cpp index a953d651a33..d007b030e6b 100644 --- a/searchcore/src/vespa/searchcore/proton/common/cachedselect.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/cachedselect.cpp @@ -9,15 +9,13 @@ #include #include -#include -LOG_SETUP(".proton.common.cachedselect"); - namespace proton { using search::AttributeVector; using search::AttributeGuard; using document::select::FieldValueNode; using search::attribute::CollectionType; +using search::attribute::BasicType; using NodeUP = std::unique_ptr; @@ -42,7 +40,7 @@ public: } AttrVisitor(const search::IAttributeManager &amgr, CachedSelect::AttributeVectors &attributes); - ~AttrVisitor(); + ~AttrVisitor() override; /* * Mutate field value nodes representing single value attributes into @@ -62,7 +60,11 @@ AttrVisitor::AttrVisitor(const search::IAttributeManager &amgr, CachedSelect::At _complexAttrs(0u) {} -AttrVisitor::~AttrVisitor() { } +AttrVisitor::~AttrVisitor() = default; + +bool isSingleValueThatWEHandle(BasicType type) { + return (type != BasicType::PREDICATE) && (type != BasicType::TENSOR) && (type != BasicType::REFERENCE); +} void AttrVisitor::visitFieldValueNode(const FieldValueNode &expr) @@ -83,20 +85,26 @@ AttrVisitor::visitFieldValueNode(const FieldValueNode &expr) } std::shared_ptr av(ag->getSP()); if (av->getCollectionType() == CollectionType::SINGLE) { - ++_svAttrs; - AttrMap::iterator it(_amap.find(name)); - uint32_t idx(invalidIdx()); - if (it == _amap.end()) { - // Allocate new location for guard - idx = _attributes.size(); - _amap[name] = idx; - _attributes.push_back(av); + if (isSingleValueThatWEHandle(av->getBasicType())) { + ++_svAttrs; + auto it(_amap.find(name)); + uint32_t idx(invalidIdx()); + if (it == _amap.end()) { + // Allocate new location for guard + idx = _attributes.size(); + _amap[name] = idx; + _attributes.push_back(av); + } else { + // Already allocated location for guard + idx = it->second; + } + assert(idx != invalidIdx()); + _valueNode = std::make_unique(expr.getDocType(), name, av); } else { - // Already allocated location for guard - idx = it->second; + ++_complexAttrs; + // Don't try to optimize predicate/tensor/reference attributes yet. + _valueNode = expr.clone(); } - assert(idx != invalidIdx()); - _valueNode.reset(new AttributeFieldValueNode(expr.getDocType(), name, av)); } else { // Don't try to optimize multivalue attribute vectors yet ++_mvAttrs; @@ -186,7 +194,7 @@ CachedSelect::CachedSelect() _preDocSelect() { } -CachedSelect::~CachedSelect() { } +CachedSelect::~CachedSelect() = default; void CachedSelect::set(const vespalib::string &selection, -- cgit v1.2.3