add fuzzy search

This commit is contained in:
yihaoDeng 2022-03-31 10:16:04 +08:00
parent baf28eced5
commit f2c9f40dff
1 changed files with 19 additions and 2 deletions

View File

@ -193,9 +193,26 @@ void dfaAdd(FstDfa *dfa, FstSparseSet *set, uint32_t ip) {
dfaAdd(dfa, set, inst->sv.len1); dfaAdd(dfa, set, inst->sv.len1);
dfaAdd(dfa, set, inst->sv.len2); dfaAdd(dfa, set, inst->sv.len2);
} }
return; return;
} }
bool dfaRun(FstDfa *dfa, FstSparseSet *from, FstSparseSet *to, uint8_t byte) { bool dfaRun(FstDfa *dfa, FstSparseSet *from, FstSparseSet *to, uint8_t byte) {
// impl run bool isMatch = false;
return true; sparSetClear(to);
for (int i = 0; i < sparSetLen(from); i++) {
uint32_t ip = sparSetGet(from, i);
Inst *inst = taosArrayGet(dfa->insts, ip);
if (inst->ty == JUMP || inst->ty == SPLIT) {
continue;
} else if (inst->ty == MATCH) {
isMatch = true;
} else if (inst->ty == RANGE) {
if (inst->rv.start <= byte && byte <= inst->rv.end) {
dfaAdd(dfa, to, ip + 1);
}
}
}
return isMatch;
} }