[Groonga-commit] groonga/groonga at 620ad39 [6.1.0-41-3fd04c3-hot-fix-broken-index-in-vector-column] Fix a bug that vector column index doesn't remove all posting lists on clean

Back to archive index
Kouhei Sutou null+****@clear*****
Sat Nov 10 02:30:59 JST 2018


Kouhei Sutou	2018-11-10 02:30:59 +0900 (Sat, 10 Nov 2018)

  Revision: 620ad390fc2bf18ca547218a52dd61d967cf3900
  https://github.com/groonga/groonga/commit/620ad390fc2bf18ca547218a52dd61d967cf3900

  Message:
    Fix a bug that vector column index doesn't remove all posting lists on clean
    
    GitHub: fix pgroonga/pgroonga#85
    
    Reported by dodaisuke. Thanks!!!

  Added files:
    test/command/suite/select/index/vector/delete.expected
    test/command/suite/select/index/vector/delete.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+29 -4)
===================================================================
--- lib/db.c    2016-11-16 15:59:59 +0900 (57478c5f4)
+++ lib/db.c    2018-11-10 02:30:59 +0900 (888f843b5)
@@ -1828,16 +1828,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;
 }

  Added: test/command/suite/select/index/vector/delete.expected (+113 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/vector/delete.expected    2018-11-10 02:30:59 +0900 (e7f6816f3)
@@ -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",
+        [
+
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/index/vector/delete.test (+33 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/index/vector/delete.test    2018-11-10 02:30:59 +0900 (0adc8480e)
@@ -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'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181110/84de4688/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index