diff options
6 files changed, 14 insertions, 60 deletions
diff --git a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp index 659d7da2fe0..1491f41aeb9 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -8,7 +8,7 @@ #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/attribute/attributevector.h> #include <vespa/searchlib/attribute/attribute_read_guard.h> -#include <vespa/searchlib/attribute/extendableattributes.h> +#include <vespa/searchlib/attribute/singlestringattribute.h> #include <vespa/searchlib/attribute/iattributemanager.h> #include <vespa/searchlib/attribute/predicate_attribute.h> #include <vespa/searchlib/attribute/singlenumericattribute.h> @@ -35,7 +35,6 @@ using search::AttributeGuard; using search::AttributeVector; using search::IAttributeManager; using search::IntegerAttribute; -using search::SingleStringExtAttribute; using search::attribute::IAttributeContext; using search::fef::MatchData; using search::fef::MatchDataLayout; @@ -266,9 +265,11 @@ bool search(const string &term, IAttributeManager &attribute_manager, } template <typename T> struct AttributeVectorTypeFinder { - //typedef search::SingleValueStringAttribute Type; - typedef SingleStringExtAttribute Type; - static void add(Type & a, const T & v) { a.add(v, weight); } + typedef search::SingleValueStringAttribute Type; + static void add(Type & a, const T & v) { + a.update(a.getNumDocs()-1, v); + a.commit(); + } }; template <> struct AttributeVectorTypeFinder<int64_t> { typedef search::SingleValueNumericAttribute<search::IntegerAttributeTemplate<int64_t> > Type; diff --git a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp index a3a43e09ae5..87d9f081ffc 100644 --- a/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp +++ b/searchlib/src/tests/attribute/stringattribute/stringattribute_test.cpp @@ -386,7 +386,7 @@ testSingleValue(Attribute & svsa, Config &cfg) TEST("testSingleValue") { EXPECT_EQUAL(24u, sizeof(AttributeVector::SearchContext)); - EXPECT_EQUAL(80u, sizeof(SingleValueStringAttribute::StringSingleImplSearchContext)); + EXPECT_EQUAL(72u, sizeof(SingleValueStringAttribute::StringSingleImplSearchContext)); { Config cfg(BasicType::STRING, CollectionType::SINGLE); SingleValueStringAttribute svsa("svsa", cfg); diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp index 80f72aaea25..0912c162e82 100644 --- a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp @@ -22,6 +22,11 @@ StringDirectAttribute(const vespalib::string & baseFileName, const Config & c) StringDirectAttribute::~StringDirectAttribute() = default; +AttributeVector::SearchContext::UP +StringDirectAttribute::getSearch(QueryTermSimpleUP, const attribute::SearchContextParams &) const { + LOG_ABORT("StringDirectAttribute::getSearch is not implemented and should never be called."); +} + bool StringDirectAttribute::findEnum(const char * key, EnumHandle & e) const { if (_offsets.size() < 1) { diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.h b/searchlib/src/vespa/searchlib/attribute/attrvector.h index eb6d2eebb84..e1f8338a4ea 100644 --- a/searchlib/src/vespa/searchlib/attribute/attrvector.h +++ b/searchlib/src/vespa/searchlib/attribute/attrvector.h @@ -142,6 +142,7 @@ private: bool onLoad() override; const char * getFromEnum(EnumHandle e) const override { return &_buffer[e]; } const char * getStringFromEnum(EnumHandle e) const override { return &_buffer[e]; } + SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; protected: StringDirectAttribute(const vespalib::string & baseFileName, const Config & c); ~StringDirectAttribute() override; diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.cpp b/searchlib/src/vespa/searchlib/attribute/stringbase.cpp index 78225a59b66..d64e03c67a4 100644 --- a/searchlib/src/vespa/searchlib/attribute/stringbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/stringbase.cpp @@ -20,12 +20,6 @@ IMPLEMENT_IDENTIFIABLE_ABSTRACT(StringAttribute, AttributeVector); using attribute::LoadedEnumAttribute; using attribute::LoadedEnumAttributeVector; -AttributeVector::SearchContext::UP -StringAttribute::getSearch(QueryTermSimple::UP term, const attribute::SearchContextParams &) const -{ - return std::make_unique<StringSearchContext>(std::move(term), *this); -} - class SortDataChar { public: SortDataChar() { } @@ -232,9 +226,7 @@ StringAttribute::StringSearchContext::StringSearchContext(QueryTermSimple::UP qT SearchContext(toBeSearched), _queryTerm(static_cast<QueryTermUCS4 *>(qTerm.release())), _termUCS4(queryTerm()->getUCS4Term()), - _buffer(nullptr), _regex(), - _bufferLen(toBeSearched.getMaxValueCount()), _isPrefix(_queryTerm->isPrefix()), _isRegex(_queryTerm->isRegex()) { @@ -243,12 +235,7 @@ StringAttribute::StringSearchContext::StringSearchContext(QueryTermSimple::UP qT } } -StringAttribute::StringSearchContext::~StringSearchContext() -{ - if (_buffer != nullptr) { - delete [] _buffer; - } -} +StringAttribute::StringSearchContext::~StringSearchContext() = default; bool StringAttribute::StringSearchContext::valid() const @@ -284,33 +271,6 @@ public: } -int32_t -StringAttribute::StringSearchContext::onFind(DocId docId, int32_t elemId, int32_t &weight) const -{ - WeightedConstChar * buffer = getBuffer(); - uint32_t valueCount = attribute().get(docId, buffer, _bufferLen); - - CollectWeight collector; - DirectAccessor accessor; - int32_t foundElem = findNextMatch(vespalib::ConstArrayRef<WeightedConstChar>(buffer, std::min(valueCount, _bufferLen)), elemId, accessor, collector); - weight = collector.getWeight(); - return foundElem; -} - -int32_t -StringAttribute::StringSearchContext::onFind(DocId docId, int32_t elemId) const -{ - WeightedConstChar * buffer = getBuffer(); - uint32_t valueCount = attribute().get(docId, buffer, _bufferLen); - for (uint32_t i = elemId, m = std::min(valueCount, _bufferLen); (i < m); i++) { - if (isMatch(buffer[i].getValue())) { - return i; - } - } - - return -1; -} - bool StringAttribute::applyWeight(DocId doc, const FieldValue & fv, const ArithmeticValueUpdate & wAdjust) { diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.h b/searchlib/src/vespa/searchlib/attribute/stringbase.h index 36c3d113b03..d72f7002086 100644 --- a/searchlib/src/vespa/searchlib/attribute/stringbase.h +++ b/searchlib/src/vespa/searchlib/attribute/stringbase.h @@ -152,29 +152,16 @@ protected: return -1; } - - int32_t onFind(DocId docId, int32_t elementId, int32_t &weight) const override; - int32_t onFind(DocId docId, int32_t elementId) const override; - bool isPrefix() const { return _isPrefix; } bool isRegex() const { return _isRegex; } const vespalib::Regex & getRegex() const { return _regex; } private: - WeightedConstChar * getBuffer() const { - if (_buffer == nullptr) { - _buffer = new WeightedConstChar[_bufferLen]; - } - return _buffer; - } std::unique_ptr<QueryTermUCS4> _queryTerm; std::vector<ucs4_t> _termUCS4; - mutable WeightedConstChar * _buffer; vespalib::Regex _regex; - unsigned _bufferLen; bool _isPrefix; bool _isRegex; }; - SearchContext::UP getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; }; } |