[Groonga-commit] groonga/groonga at 61efd03 [master] index_column_diff: add support for _key

Back to archive index
Kouhei Sutou null+****@clear*****
Tue Mar 19 15:42:04 JST 2019


Kouhei Sutou	2019-03-19 15:42:04 +0900 (Tue, 19 Mar 2019)

  Revision: 61efd03ea7dc2bbc2268f9e5d48ce2d8250940db
  https://github.com/groonga/groonga/commit/61efd03ea7dc2bbc2268f9e5d48ce2d8250940db

  Message:
    index_column_diff: add support for _key

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

  Modified: lib/index_column.c (+6 -0)
===================================================================
--- lib/index_column.c    2019-03-19 15:36:28 +0900 (cb4c33d30)
+++ lib/index_column.c    2019-03-19 15:42:04 +0900 (04bcece1e)
@@ -705,6 +705,12 @@ grn_index_column_diff(grn_ctx *ctx,
     for (size_t i = 0; i < n_columns; i++) {
       grn_id source_id = GRN_RECORD_VALUE_AT(&source_columns, i);
       grn_obj *source = grn_ctx_at(ctx, source_id);
+      if (grn_obj_is_table(ctx, source)) {
+        source = grn_obj_column(ctx,
+                                source,
+                                GRN_COLUMN_NAME_KEY,
+                                GRN_COLUMN_NAME_KEY_LEN);
+      }
       GRN_PTR_PUT(ctx, &(data.source_columns), source);
     }
     GRN_OBJ_FIN(ctx, &source_columns);

  Added: test/command/suite/index_column_diff/key.expected (+79 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/key.expected    2019-03-19 15:42:04 +0900 (d1181af80)
@@ -0,0 +1,79 @@
+table_create Data TABLE_HASH_KEY ShortText
+[[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 Data _key
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"_key": "Hello World"},
+{"_key": "Hello Groonga"}
+]
+[[0,0.0,0.0],2]
+truncate Terms.data_index
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"_key": "Good-by World"},
+{"_key": "Good-by Groonga"}
+]
+[[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,
+          "position": 0
+        },
+        {
+          "record_id": 2,
+          "position": 0
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 2,
+        "value": "world"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1,
+          "position": 1
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 3,
+        "value": "groonga"
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 2,
+          "position": 1
+        }
+      ]
+    }
+  ]
+]

  Added: test/command/suite/index_column_diff/key.test (+22 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/key.test    2019-03-19 15:42:04 +0900 (f136bc8cb)
@@ -0,0 +1,22 @@
+table_create Data TABLE_HASH_KEY ShortText
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenNgram \
+  --normalizer NormalizerNFKC100
+column_create Terms data_index COLUMN_INDEX|WITH_POSITION Data _key
+
+load --table Data
+[
+{"_key": "Hello World"},
+{"_key": "Hello Groonga"}
+]
+
+truncate Terms.data_index
+
+load --table Data
+[
+{"_key": "Good-by World"},
+{"_key": "Good-by Groonga"}
+]
+
+index_column_diff Terms data_index
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190319/3c23afd9/attachment-0001.html>


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