Skip to content

Commit

Permalink
Fix a bug that vector column index doesn't remove all posting lists o…
Browse files Browse the repository at this point in the history
…n clean

GitHub: fix pgroonga/pgroonga#85

Reported by dodaisuke. Thanks!!!
  • Loading branch information
kou authored and komainu8 committed Nov 19, 2018
1 parent 9f5cadc commit 423b6fe
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 4 deletions.
33 changes: 29 additions & 4 deletions lib/db.c
Expand Up @@ -1801,16 +1801,41 @@ grn_obj_clear_value(grn_ctx *ctx, grn_obj *obj, grn_id id)
{
grn_rc rc = GRN_SUCCESS;
if (GRN_DB_OBJP(obj)) {
grn_obj buf;
grn_id range = DB_OBJ(obj)->range;
GRN_OBJ_INIT(&buf, GRN_BULK, 0, range);
switch (obj->header.type) {
case GRN_COLUMN_VAR_SIZE :
switch (obj->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) {
case GRN_OBJ_COLUMN_SCALAR :
{
grn_obj buf;
GRN_OBJ_INIT(&buf, GRN_BULK, 0, range);
rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
GRN_OBJ_FIN(ctx, &buf);
}
break;
case GRN_OBJ_COLUMN_VECTOR :
{
grn_obj buf;
GRN_OBJ_INIT(&buf, GRN_VECTOR, 0, range);
rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
GRN_OBJ_FIN(ctx, &buf);
}
break;
default :
break;
}
break;
case GRN_COLUMN_FIX_SIZE :
rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
{
grn_obj buf;
GRN_OBJ_INIT(&buf, GRN_BULK, 0, range);
rc = grn_obj_set_value(ctx, obj, id, &buf, GRN_OBJ_SET);
GRN_OBJ_FIN(ctx, &buf);
}
break;
default :
break;
}
GRN_OBJ_FIN(ctx, &buf);
}
return rc;
}
Expand Down
113 changes: 113 additions & 0 deletions test/command/suite/select/index/vector/delete.expected
@@ -0,0 +1,113 @@
plugin_register functions/index_column
[[0,0.0,0.0],true]
table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
[[0,0.0,0.0],true]
table_create Memos TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Memos tags COLUMN_VECTOR ShortText
[[0,0.0,0.0],true]
column_create Terms memos COLUMN_INDEX|WITH_POSITION|WITH_SECTION Memos tags
[[0,0.0,0.0],true]
load --table Memos
[
{
"_key": "Groonga",
"tags": ["groonga", "full-text-search"]
}
]
[[0,0.0,0.0],1]
delete --table Memos --filter true
[[0,0.0,0.0],true]
select Memos
[
[
0,
0.0,
0.0
],
[
[
[
0
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"tags",
"ShortText"
]
]
]
]
]
select Terms --limit -1 --sort_keys _id --columns[index_records].stage output --columns[index_records].type Memos --columns[index_records].flags COLUMN_VECTOR --columns[index_records].value 'index_column_source_records("memos")' --output_columns '_id, _key, index_records'
[
[
0,
0.0,
0.0
],
[
[
[
5
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"index_records",
"Memos"
]
],
[
1,
"groonga",
[

]
],
[
2,
"full",
[

]
],
[
3,
"-",
[

]
],
[
4,
"text",
[

]
],
[
5,
"search",
[

]
]
]
]
]
33 changes: 33 additions & 0 deletions test/command/suite/select/index/vector/delete.test
@@ -0,0 +1,33 @@
plugin_register functions/index_column

table_create Terms TABLE_PAT_KEY ShortText \
--default_tokenizer TokenBigram \
--normalizer NormalizerAuto

table_create Memos TABLE_HASH_KEY ShortText
column_create Memos tags COLUMN_VECTOR ShortText

column_create Terms memos \
COLUMN_INDEX|WITH_POSITION|WITH_SECTION \
Memos tags

load --table Memos
[
{
"_key": "Groonga",
"tags": ["groonga", "full-text-search"]
}
]

delete --table Memos --filter true

select Memos

select Terms \
--limit -1 \
--sort_keys _id \
--columns[index_records].stage output \
--columns[index_records].type Memos \
--columns[index_records].flags COLUMN_VECTOR \
--columns[index_records].value 'index_column_source_records("memos")' \
--output_columns '_id, _key, index_records'

0 comments on commit 423b6fe

Please sign in to comment.