diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-12-19 17:02:19 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-01-04 10:42:37 +0000 |
commit | 0f9915ebdfb2931ebb3c06ac55b537f42477256b (patch) | |
tree | a6f3a41e547c032d773ef391da22ca04bcfcacc3 /streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp | |
parent | 5f1ec31a0decec88322835705afa26cc7d35fd3e (diff) |
- Modernize code
- Unify some conversion tables.
Diffstat (limited to 'streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp')
-rw-r--r-- | streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp | 152 |
1 files changed, 70 insertions, 82 deletions
diff --git a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp index c797e6751ee..851606634cc 100644 --- a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp +++ b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp @@ -28,26 +28,24 @@ static force __forceInit; byte FieldSearcher::_foldLowCase[256]; byte FieldSearcher::_wordChar[256]; -FieldSearcherBase::FieldSearcherBase() : - _qtl(), - _qtlFastBuffer(), - _qtlFastSize(0), - _qtlFast(nullptr) +FieldSearcherBase::FieldSearcherBase() noexcept + : _qtl(), + _qtlFastBuffer(), + _qtlFastSize(0), + _qtlFast(nullptr) { } -FieldSearcherBase::FieldSearcherBase(const FieldSearcherBase & org) : - _qtl(), - _qtlFastBuffer(), - _qtlFastSize(0), - _qtlFast(nullptr) +FieldSearcherBase::FieldSearcherBase(const FieldSearcherBase & org) + : _qtl(), + _qtlFastBuffer(), + _qtlFastSize(0), + _qtlFast(nullptr) { prepare(org._qtl); } -FieldSearcherBase::~FieldSearcherBase() -{ -} +FieldSearcherBase::~FieldSearcherBase() = default; FieldSearcherBase & FieldSearcherBase::operator = (const FieldSearcherBase & org) { @@ -68,20 +66,16 @@ void FieldSearcherBase::prepare(const QueryTermList & qtl) } } -FieldSearcher::FieldSearcher(FieldIdT fId, bool defaultPrefix) : - FieldSearcherBase(), - _field(fId), - _matchType(defaultPrefix ? PREFIX : REGULAR), - _maxFieldLength(0x100000), - _currentElementId(0), - _currentElementWeight(1), - _pureUsAsciiCount(0), - _pureUsAsciiFieldCount(0), - _anyUtf8Count(0), - _anyUtf8FieldCount(0), - _words(0), - _badUtf8Count(0), - _zeroCount(0) +FieldSearcher::FieldSearcher(FieldIdT fId, bool defaultPrefix) noexcept + : FieldSearcherBase(), + _field(fId), + _matchType(defaultPrefix ? PREFIX : REGULAR), + _maxFieldLength(0x100000), + _currentElementId(0), + _currentElementWeight(1), + _words(0), + _badUtf8Count(0), + _zeroCount(0) { zeroStat(); } @@ -136,26 +130,10 @@ void FieldSearcher::prepareFieldId() } } -void FieldSearcher::addStat(const FieldSearcher & toAdd) -{ - _pureUsAsciiCount += toAdd._pureUsAsciiCount; - _pureUsAsciiFieldCount += toAdd._pureUsAsciiFieldCount; - _anyUtf8Count += toAdd._anyUtf8Count; - _anyUtf8FieldCount += toAdd._anyUtf8FieldCount; - _badUtf8Count += toAdd._badUtf8Count; - _zeroCount += toAdd._zeroCount; - for (size_t i=0; i<NELEMS(_utf8Count); i++) { _utf8Count[i] += toAdd._utf8Count[i]; } -} - void FieldSearcher::zeroStat() { - _pureUsAsciiCount = 0; - _pureUsAsciiFieldCount = 0; - _anyUtf8Count = 0; - _anyUtf8FieldCount = 0; _badUtf8Count = 0; _zeroCount = 0; - for (size_t i=0; i<NELEMS(_utf8Count); i++) { _utf8Count[i] = 0; } } void FieldSearcher::init() @@ -182,43 +160,53 @@ void FieldSearcher::init() _wordChar[0xd7] = 0; _wordChar[0xf7] = 0; - if (1) /* _doAccentRemoval */ { - _foldLowCase[0xc0] = 'a'; - _foldLowCase[0xc1] = 'a'; - _foldLowCase[0xc2] = 'a'; - _foldLowCase[0xc3] = 'a'; // A tilde - _foldLowCase[0xc7] = 'c'; - _foldLowCase[0xc8] = 'e'; - _foldLowCase[0xc9] = 'e'; - _foldLowCase[0xca] = 'e'; - _foldLowCase[0xcb] = 'e'; - _foldLowCase[0xcc] = 'i'; // I grave - _foldLowCase[0xcd] = 'i'; - _foldLowCase[0xce] = 'i'; - _foldLowCase[0xcf] = 'i'; - _foldLowCase[0xd3] = 'o'; - _foldLowCase[0xd4] = 'o'; - _foldLowCase[0xda] = 'u'; - _foldLowCase[0xdb] = 'u'; - - _foldLowCase[0xe0] = 'a'; - _foldLowCase[0xe1] = 'a'; - _foldLowCase[0xe2] = 'a'; - _foldLowCase[0xe3] = 'a'; // a tilde - _foldLowCase[0xe7] = 'c'; - _foldLowCase[0xe8] = 'e'; - _foldLowCase[0xe9] = 'e'; - _foldLowCase[0xea] = 'e'; - _foldLowCase[0xeb] = 'e'; - _foldLowCase[0xec] = 'i'; // i grave - _foldLowCase[0xed] = 'i'; - _foldLowCase[0xee] = 'i'; - _foldLowCase[0xef] = 'i'; - _foldLowCase[0xf3] = 'o'; - _foldLowCase[0xf4] = 'o'; - _foldLowCase[0xfa] = 'u'; - _foldLowCase[0xfb] = 'u'; - } + _foldLowCase[0xc0] = 'a'; + _foldLowCase[0xc1] = 'a'; + _foldLowCase[0xc2] = 'a'; + _foldLowCase[0xc3] = 'a'; + _foldLowCase[0xc7] = 'c'; + _foldLowCase[0xc8] = 'e'; + _foldLowCase[0xc9] = 'e'; + _foldLowCase[0xca] = 'e'; + _foldLowCase[0xcb] = 'e'; + _foldLowCase[0xcc] = 'i'; + _foldLowCase[0xcd] = 'i'; + _foldLowCase[0xce] = 'i'; + _foldLowCase[0xcf] = 'i'; + _foldLowCase[0xd1] = 'n'; + _foldLowCase[0xd2] = 'o'; + _foldLowCase[0xd3] = 'o'; + _foldLowCase[0xd4] = 'o'; + _foldLowCase[0xd5] = 'o'; + _foldLowCase[0xd9] = 'u'; + _foldLowCase[0xda] = 'u'; + _foldLowCase[0xdb] = 'u'; + _foldLowCase[0xdc] = 'u'; + _foldLowCase[0xdd] = 'y'; + _foldLowCase[0xe0] = 'a'; + _foldLowCase[0xe1] = 'a'; + _foldLowCase[0xe2] = 'a'; + _foldLowCase[0xe3] = 'a'; + _foldLowCase[0xe7] = 'c'; + _foldLowCase[0xe8] = 'e'; + _foldLowCase[0xe9] = 'e'; + _foldLowCase[0xea] = 'e'; + _foldLowCase[0xeb] = 'e'; + _foldLowCase[0xec] = 'i'; + _foldLowCase[0xed] = 'i'; + _foldLowCase[0xee] = 'i'; + _foldLowCase[0xef] = 'i'; + _foldLowCase[0xf1] = 'n'; + _foldLowCase[0xf2] = 'o'; + _foldLowCase[0xf3] = 'o'; + _foldLowCase[0xf4] = 'o'; + _foldLowCase[0xf5] = 'o'; + _foldLowCase[0xf9] = 'u'; + _foldLowCase[0xfa] = 'u'; + _foldLowCase[0xfb] = 'u'; + _foldLowCase[0xfc] = 'u'; + _foldLowCase[0xfd] = 'y'; + _foldLowCase[0xff] = 'y'; } void FieldIdTSearcherMap::prepare(const DocumentTypeIndexFieldMapT& difm, @@ -296,10 +284,10 @@ FieldSearcher::IteratorHandler::onCollectionStart(const Content & c) const document::FieldValue & fv = c.getValue(); LOG(spam, "onCollectionStart: field value '%s'", fv.toString().c_str()); if (fv.isA(document::FieldValue::Type::ARRAY)) { - const document::ArrayFieldValue & afv = static_cast<const document::ArrayFieldValue &>(fv); + const auto & afv = static_cast<const document::ArrayFieldValue &>(fv); LOG(spam, "onCollectionStart: Array size = '%zu'", afv.size()); } else if (fv.isA(document::FieldValue::Type::WSET)) { - const document::WeightedSetFieldValue & wsfv = static_cast<const document::WeightedSetFieldValue &>(fv); + const auto & wsfv = static_cast<const document::WeightedSetFieldValue &>(fv); LOG(spam, "onCollectionStart: WeightedSet size = '%zu'", wsfv.size()); } } |