[Groonga-commit] groonga/groonga at 73c3ad0 [master] index_column_diff: ignore invalid reference

Back to archive index
Kouhei Sutou null+****@clear*****
Fri May 17 14:38:31 JST 2019


Kouhei Sutou	2019-05-17 14:38:31 +0900 (Fri, 17 May 2019)

  Revision: 73c3ad01e3e6367862aa18a986b01916aa5f0534
  https://github.com/groonga/groonga/commit/73c3ad01e3e6367862aa18a986b01916aa5f0534

  Message:
    index_column_diff: ignore invalid reference

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

  Modified: lib/index_column.c (+7 -2)
===================================================================
--- lib/index_column.c    2019-05-17 14:24:59 +0900 (23c709673)
+++ lib/index_column.c    2019-05-17 14:38:31 +0900 (0a67d4815)
@@ -1032,6 +1032,9 @@ grn_index_column_diff_compute(grn_ctx *ctx,
           for (size_t j = 0; j < n_elements; j++) {
             const grn_id element =
               grn_uvector_get_element(ctx, value, j, NULL);
+            if (element == GRN_ID_NIL) {
+              continue;
+            }
             data->current.token_id = element;
             data->current.posting.pos = 0;
             grn_index_column_diff_process_token_id(ctx, data);
@@ -1061,8 +1064,10 @@ grn_index_column_diff_compute(grn_ctx *ctx,
         if (GRN_BULK_VSIZE(value) > 0) {
           if (is_reference) {
             data->current.token_id = GRN_RECORD_VALUE(value);
-            data->current.posting.pos = 0;
-            grn_index_column_diff_process_token_id(ctx, data);
+            if (data->current.token_id != GRN_ID_NIL) {
+              data->current.posting.pos = 0;
+              grn_index_column_diff_process_token_id(ctx, data);
+            }
           } else {
             grn_index_column_diff_process_token(ctx,
                                                 data,

  Modified: test/command/suite/index_column_diff/reference.expected (+3 -2)
===================================================================
--- test/command/suite/index_column_diff/reference.expected    2019-05-17 14:24:59 +0900 (195fc7e95)
+++ test/command/suite/index_column_diff/reference.expected    2019-05-17 14:38:31 +0900 (b0027cbef)
@@ -17,9 +17,10 @@ truncate Values.data_index
 load --table Data
 [
 {"value": "Good-by World"},
-{"value": "Good-by Groonga"}
+{"value": "Good-by Groonga"},
+{}
 ]
-[[0,0.0,0.0],2]
+[[0,0.0,0.0],3]
 index_column_diff Values data_index
 [
   [

  Modified: test/command/suite/index_column_diff/reference.test (+2 -1)
===================================================================
--- test/command/suite/index_column_diff/reference.test    2019-05-17 14:24:59 +0900 (b0e9e94ee)
+++ test/command/suite/index_column_diff/reference.test    2019-05-17 14:38:31 +0900 (14f530875)
@@ -16,7 +16,8 @@ truncate Values.data_index
 load --table Data
 [
 {"value": "Good-by World"},
-{"value": "Good-by Groonga"}
+{"value": "Good-by Groonga"},
+{}
 ]
 
 index_column_diff Values data_index
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190517/8d04c3c4/attachment-0001.html>


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