[Groonga-commit] groonga/groonga at 249ddfc [master] index_column_diff: add support for fixed size vector column

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


Kouhei Sutou	2019-03-23 07:08:25 +0900 (Sat, 23 Mar 2019)

  Revision: 249ddfc5a7eaf862cef3725b1a1315aa6804adf2
  https://github.com/groonga/groonga/commit/249ddfc5a7eaf862cef3725b1a1315aa6804adf2

  Message:
    index_column_diff: add support for fixed size vector column

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

  Modified: lib/index_column.c (+14 -1)
===================================================================
--- lib/index_column.c    2019-03-23 06:58:22 +0900 (7d3e9cd42)
+++ lib/index_column.c    2019-03-23 07:08:25 +0900 (899e29758)
@@ -828,7 +828,7 @@ grn_index_column_diff_compute(grn_ctx *ctx,
       case GRN_VECTOR :
         break;
       case GRN_UVECTOR :
-        {
+        if (is_reference) {
           const size_t n_elements = grn_uvector_size(ctx, value);
           for (size_t i = 0; i < n_elements; i++) {
             const grn_id element =
@@ -837,6 +837,19 @@ grn_index_column_diff_compute(grn_ctx *ctx,
             data->current.posting.pos = 0;
             grn_index_column_diff_process_token_id(ctx, data);
           }
+        } else {
+          const size_t n_elements = grn_uvector_size(ctx, value);
+          const size_t element_size = grn_uvector_element_size(ctx, value);
+          for (size_t i = 0; i < n_elements; i++) {
+            const char *element = GRN_BULK_HEAD(value) + (element_size * i);
+            data->current.token_id =
+              grn_table_get(ctx, data->lexicon, element, element_size);
+            if (data->current.token_id == GRN_ID_NIL) {
+              continue;
+            }
+            data->current.posting.pos = 0;
+            grn_index_column_diff_process_token_id(ctx, data);
+          }
         }
         break;
       case GRN_BULK :

  Added: test/command/suite/index_column_diff/int64_vector.expected (+88 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/int64_vector.expected    2019-03-23 07:08:25 +0900 (ea9c860af)
@@ -0,0 +1,88 @@
+table_create Data TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Data values COLUMN_VECTOR Int64
+[[0,0.0,0.0],true]
+table_create Numbers TABLE_HASH_KEY Int64
+[[0,0.0,0.0],true]
+column_create Numbers data_index COLUMN_INDEX Data values
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"values": [-9223372036854775808, 9223372036854775807]},
+{"values": [-9223372036854775807, 9223372036854775806]}
+]
+[[0,0.0,0.0],2]
+truncate Numbers.data_index
+[[0,0.0,0.0],true]
+load --table Data
+[
+{"values": [-1, 1]},
+{"values": [-2, 2]}
+]
+[[0,0.0,0.0],2]
+index_column_diff Numbers data_index
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    {
+      "token": {
+        "id": 1,
+        "value": -9223372036854775808
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 2,
+        "value": 9223372036854775807
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 1
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 3,
+        "value": -9223372036854775807
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 2
+        }
+      ]
+    },
+    {
+      "token": {
+        "id": 4,
+        "value": 9223372036854775806
+      },
+      "remains": [
+
+      ],
+      "missings": [
+        {
+          "record_id": 2
+        }
+      ]
+    }
+  ]
+]

  Added: test/command/suite/index_column_diff/int64_vector.test (+21 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/index_column_diff/int64_vector.test    2019-03-23 07:08:25 +0900 (926e1feb9)
@@ -0,0 +1,21 @@
+table_create Data TABLE_NO_KEY
+column_create Data values COLUMN_VECTOR Int64
+
+table_create Numbers TABLE_HASH_KEY Int64
+column_create Numbers data_index COLUMN_INDEX Data values
+
+load --table Data
+[
+{"values": [-9223372036854775808, 9223372036854775807]},
+{"values": [-9223372036854775807, 9223372036854775806]}
+]
+
+truncate Numbers.data_index
+
+load --table Data
+[
+{"values": [-1, 1]},
+{"values": [-2, 2]}
+]
+
+index_column_diff Numbers data_index
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190323/ba41e9f9/attachment-0001.html>


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