blob: 0d93009655c9d3db72663071988af96d14abdd69 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "utf8strchrfieldsearcher.h"
using search::streaming::QueryTerm;
using search::streaming::QueryTermList;
using search::byte;
namespace vsm {
std::unique_ptr<FieldSearcher>
UTF8StrChrFieldSearcher::duplicate() const
{
return std::make_unique<UTF8StrChrFieldSearcher>(*this);
}
size_t
UTF8StrChrFieldSearcher::matchTerms(const FieldRef & f, const size_t mintsz)
{
(void) mintsz;
termcount_t words(0);
const byte * n = reinterpret_cast<const byte *> (f.data());
const byte * e = n + f.size();
if (f.size() >= _buf->size()) {
_buf->reserve(f.size() + 1);
}
cmptype_t * fn = &(*_buf.get())[0];
size_t fl(0);
for( ; n < e; ) {
if (!*n) { _zeroCount++; n++; }
n = tokenize(n, _buf->capacity(), fn, fl);
for(QueryTermList::iterator it=_qtl.begin(), mt=_qtl.end(); it != mt; it++) {
QueryTerm & qt = **it;
const cmptype_t * term;
termsize_t tsz = qt.term(term);
if ((tsz <= fl) && (prefix() || qt.isPrefix() || (tsz == fl))) {
const cmptype_t *tt=term, *et=term+tsz;
for (const cmptype_t *fnt=fn; (tt < et) && (*tt == *fnt); tt++, fnt++);
if (tt == et) {
addHit(qt, words);
}
}
}
words++;
}
NEED_CHAR_STAT(addAnyUtf8Field(f.size()));
return words;
}
size_t
UTF8StrChrFieldSearcher::matchTerm(const FieldRef & f, QueryTerm & qt)
{
return matchTermRegular(f, qt);
}
}
|