summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-11-22 16:28:12 +0100
committerTor Egge <Tor.Egge@online.no>2023-11-22 16:28:12 +0100
commit66eaacb62cf323321b336dcb3619f990f9a89863 (patch)
tree5a348b2cf46b57538a09b30293f2e5ef0f820b33 /searchlib
parentec90d54ca208408952224413b41dc475443c3e36 (diff)
Move is_match() member function to .cpp file and use explicit instantiation.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.cpp40
-rw-r--r--searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.h30
2 files changed, 41 insertions, 29 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.cpp b/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.cpp
index 040bd9ccc98..9d6e2e9815d 100644
--- a/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.cpp
@@ -1,6 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "dfa_fuzzy_matcher.h"
+#include "i_enum_store_dictionary.h"
#include <vespa/vespalib/text/utf8.h>
#include <vespa/vespalib/text/lowercase.h>
@@ -94,4 +95,43 @@ DfaFuzzyMatcher::is_match(const char* word) const
return match.matches();
}
+template <typename DictionaryConstIteratorType>
+bool
+DfaFuzzyMatcher::is_match(const char* word, DictionaryConstIteratorType& itr, const DfaStringComparator::DataStoreType& data_store) {
+ if (_prefix_size > 0) {
+ word = skip_prefix(word);
+ if (_prefix.size() < _prefix_size) {
+ if (*word == '\0') {
+ return true;
+ }
+ _successor.resize(_prefix.size());
+ _successor.emplace_back(beyond_unicode);
+ } else {
+ _successor.resize(_prefix.size());
+ auto match = _dfa.match(word, _successor);
+ if (match.matches()) {
+ return true;
+ }
+ }
+ } else {
+ _successor.clear();
+ auto match = _dfa.match(word, _successor);
+ if (match.matches()) {
+ return true;
+ }
+ }
+ DfaStringComparator cmp(data_store, _successor, _cased);
+ assert(cmp.less(itr.getKey().load_acquire(), vespalib::datastore::EntryRef()));
+ itr.seek(vespalib::datastore::AtomicEntryRef(), cmp);
+ return false;
+}
+
+template
+bool
+DfaFuzzyMatcher::is_match(const char* word, EnumPostingTree::ConstIterator& itr, const DfaStringComparator::DataStoreType& data_store);
+
+template
+bool
+DfaFuzzyMatcher::is_match(const char* word, EnumTree::ConstIterator& itr, const DfaStringComparator::DataStoreType& data_store);
+
}
diff --git a/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.h b/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.h
index 590d1997e57..51457129637 100644
--- a/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.h
+++ b/searchlib/src/vespa/searchlib/attribute/dfa_fuzzy_matcher.h
@@ -5,7 +5,6 @@
#include "dfa_string_comparator.h"
#include <vespa/vespalib/datastore/atomic_entry_ref.h>
#include <vespa/vespalib/fuzzy/levenshtein_dfa.h>
-#include <iostream>
namespace search::attribute {
@@ -41,34 +40,7 @@ public:
* functionality in the dictionary.
*/
template <typename DictionaryConstIteratorType>
- bool is_match(const char* word, DictionaryConstIteratorType& itr, const DfaStringComparator::DataStoreType& data_store) {
- if (_prefix_size > 0) {
- word = skip_prefix(word);
- if (_prefix.size() < _prefix_size) {
- if (*word == '\0') {
- return true;
- }
- _successor.resize(_prefix.size());
- _successor.emplace_back(beyond_unicode);
- } else {
- _successor.resize(_prefix.size());
- auto match = _dfa.match(word, _successor);
- if (match.matches()) {
- return true;
- }
- }
- } else {
- _successor.clear();
- auto match = _dfa.match(word, _successor);
- if (match.matches()) {
- return true;
- }
- }
- DfaStringComparator cmp(data_store, _successor, _cased);
- assert(cmp.less(itr.getKey().load_acquire(), vespalib::datastore::EntryRef()));
- itr.seek(vespalib::datastore::AtomicEntryRef(), cmp);
- return false;
- }
+ bool is_match(const char* word, DictionaryConstIteratorType& itr, const DfaStringComparator::DataStoreType& data_store);
};
}