Fixed a LEAF node issue for "amzfing" with threshold of 2.

Was producing too many spurious single char matches.
This commit is contained in:
Kishore Nallan 2015-11-29 22:13:21 +05:30
parent ba39be766c
commit eb1e68620a
2 changed files with 4 additions and 3 deletions

View File

@ -1009,9 +1009,10 @@ static int art_iter_fuzzy_prefix_recurse(art_node *n, const unsigned char *term,
int row_min = 0;
int current_row[term_len+1];
copyIntArray(current_row, previous_row, term_len+1);
current_row[0] = previous_row[0] + 1;
printf("LEAF KEY: %s\n", l->key);
printf("LEAF KEY: %s, depth: %d\n", l->key, depth);
for(int idx=depth; idx<l->key_len && depth < term_len && row_min <= max_cost; idx++) {
row_min = levenshtein_score(l->key[idx], term, term_len, previous_row, current_row);

View File

@ -30,8 +30,8 @@ int main() {
num++;
}
const unsigned char *prefix = (const unsigned char *) "amazin";
art_iter_fuzzy_prefix(&t, prefix, strlen((const char *) prefix), 0, test_prefix_cb, NULL);
const unsigned char *prefix = (const unsigned char *) "amzfing";
art_iter_fuzzy_prefix(&t, prefix, strlen((const char *) prefix), 2, test_prefix_cb, NULL);
// art_iter_prefix(&t, prefix, strlen((const char *) prefix), test_prefix_cb, NULL);
// art_iter(&t, test_prefix_cb, NULL);