[Groonga-commit] groonga/groonga at 4809106 [master] index_column_diff: add support for variable size vector column

Back to archive index
Kouhei Sutou null+****@clear*****
Sat Mar 23 07:39:58 JST 2019


Kouhei Sutou	2019-03-23 07:39:58 +0900 (Sat, 23 Mar 2019)

  Revision: 480910620c4c591c5df2740f9069bab9b56eeb71
  https://github.com/groonga/groonga/commit/480910620c4c591c5df2740f9069bab9b56eeb71

  Message:
    index_column_diff: add support for variable size vector column

  Added files:
    test/command/suite/index_column_diff/text_vector.expected
    test/command/suite/index_column_diff/text_vector.test
  Modified files:
    lib/index_column.c

  Modified: lib/index_column.c (+13 -0)
===================================================================
--- lib/index_column.c    2019-03-23 07:31:36 +0900 (7c189e8c9)
+++ lib/index_column.c    2019-03-23 07:39:58 +0900 (51e05131d)
@@ -826,6 +826,19 @@ grn_index_column_diff_compute(grn_ctx *ctx,
 
       switch (value->header.type) {
       case GRN_VECTOR :
+        {
+          const size_t n_elements = grn_vector_size(ctx, value);
+          for (size_t j = 0; j < n_elements; j++) {
+            const char *element = NULL;
+            const unsigned int element_size =
+              grn_vector_get_element(ctx, value, j, &element, NULL, NULL);
+            data->current.posting.sid = j + 1;
+            grn_index_column_diff_process_token(ctx,
+                                                data,
+                                                element,
+                                                element_size);
+          }
+        }
         break;
       case GRN_UVECTOR :
         if (is_reference) {

  Added: test/command/suite/index_column_diff/text_vector.expected (+158 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/text_vector.expected    2019-03-23 07:39:58 +0900 (2adfc4a3b)
@@ -0,0 +1,158 @@
+table_create Data TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Data values COLUMN_VECTOR Text
+[[0,0.0,0.0],true]
+table_create Terms TABLE_PAT_KEY ShortText   --default_tokenizer TokenNgram   --normalizer NormalizerNFKC100
+[[0,0.0,0.0],true]
+column_create Terms data_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION   Data values
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"values": ["Hello World", "Good-by World"]},
+{"values": ["Hello Groonga", "Good-by Groonga"]}
+]
+[[0,0.0,0.0],2]
+truncate Terms.data_index
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"values": ["Morning World", "Afternoon World"]},
+{"values": ["Morning Groonga", "Afternoon World"]}
+]
+[[0,0.0,0.0],2]
+index_column_diff Terms data_index
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    {
+      "token": {
+        "id": 1,
+        "value": "hello"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "section_id": 1,
+          "position": 0
+        },
+        {
+          "record_id": 2,
+          "section_id": 1,
+          "position": 0
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 2,
+        "value": "world"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "section_id": 1,
+          "position": 1
+        },
+        {
+          "record_id": 1,
+          "section_id": 2,
+          "position": 3
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 3,
+        "value": "good"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "section_id": 2,
+          "position": 0
+        },
+        {
+          "record_id": 2,
+          "section_id": 2,
+          "position": 0
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 4,
+        "value": "-"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "section_id": 2,
+          "position": 1
+        },
+        {
+          "record_id": 2,
+          "section_id": 2,
+          "position": 1
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 5,
+        "value": "by"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "section_id": 2,
+          "position": 2
+        },
+        {
+          "record_id": 2,
+          "section_id": 2,
+          "position": 2
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 6,
+        "value": "groonga"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 2,
+          "section_id": 1,
+          "position": 1
+        },
+        {
+          "record_id": 2,
+          "section_id": 2,
+          "position": 3
+        }
+      ]
+    }
+  ]
+]

  Added: test/command/suite/index_column_diff/text_vector.test (+24 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/text_vector.test    2019-03-23 07:39:58 +0900 (c52c73a10)
@@ -0,0 +1,24 @@
+table_create Data TABLE_NO_KEY
+column_create Data values COLUMN_VECTOR Text
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenNgram \
+  --normalizer NormalizerNFKC100
+column_create Terms data_index COLUMN_INDEX|WITH_POSITION|WITH_SECTION \
+  Data values
+
+load --table Data
+[
+{"values": ["Hello World", "Good-by World"]},
+{"values": ["Hello Groonga", "Good-by Groonga"]}
+]
+
+truncate Terms.data_index
+
+load --table Data
+[
+{"values": ["Morning World", "Afternoon World"]},
+{"values": ["Morning Groonga", "Afternoon World"]}
+]
+
+index_column_diff Terms data_index
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190323/951ed9ad/attachment-0001.html>


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