aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/dfa_string_comparator.h
blob: f9eaf281ff7a9120838cd9a856d5213b552aa01a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "i_enum_store.h"
#include <vespa/vespalib/datastore/unique_store_string_comparator.h>
#include <functional>

namespace search::attribute {

/**
 * Less-than comparator used for comparing next candidate string
 * (successor) from vespa::fuzzy::LevenshteinDfa with strings stored
 * in an enum store as part of a dictionary iterator seek, skipping
 * entries that don't match the fuzzy term.
 *
 * The code points from the candidate string are not folded during
 * the comparison.
 */

class DfaStringComparator : public vespalib::datastore::UniqueStoreStringComparator<IEnumStore::InternalIndex>
{
public:
    using ParentType = vespalib::datastore::UniqueStoreStringComparator<IEnumStore::InternalIndex>;
    using DataStoreType = ParentType::DataStoreType;
private:
    using ParentType::get;
    std::reference_wrapper<const std::vector<uint32_t>> _candidate;

public:
    DfaStringComparator(const DataStoreType& data_store, const std::vector<uint32_t>& candidate);

    bool less(const vespalib::datastore::EntryRef lhs, const vespalib::datastore::EntryRef rhs) const override;
};

}