[Groonga-commit] groonga/groonga at 8ef6a95 [master] load: log N error records and columns

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Dec 4 23:00:20 JST 2017


Kouhei Sutou	2017-12-04 23:00:20 +0900 (Mon, 04 Dec 2017)

  New Revision: 8ef6a955f21c88118ea3a7f6d63c96054412f977
  https://github.com/groonga/groonga/commit/8ef6a955f21c88118ea3a7f6d63c96054412f977

  Message:
    load: log N error records and columns

  Modified files:
    lib/ctx.c
    lib/grn_ctx_impl.h
    lib/load.c
    lib/proc.c
    test/command/suite/load/command_version/3/query_log.expected
    test/command/suite/load/command_version/3/query_log.test
    test/command/suite/load/query_log.expected
    test/command/suite/load/query_log.test

  Modified: lib/ctx.c (+2 -0)
===================================================================
--- lib/ctx.c    2017-12-04 22:44:18 +0900 (e66aff2b5)
+++ lib/ctx.c    2017-12-04 23:00:20 +0900 (c99d53e7b)
@@ -159,6 +159,8 @@ grn_loader_init(grn_loader *loader)
   loader->each = NULL;
   loader->values_size = 0;
   loader->nrecords = 0;
+  loader->n_record_errors = 0;
+  loader->n_column_errors = 0;
   loader->stat = GRN_LOADER_BEGIN;
   loader->columns_status = GRN_LOADER_COLUMNS_UNSET;
   loader->rc = GRN_SUCCESS;

  Modified: lib/grn_ctx_impl.h (+3 -1)
===================================================================
--- lib/grn_ctx_impl.h    2017-12-04 22:44:18 +0900 (4050c37cb)
+++ lib/grn_ctx_impl.h    2017-12-04 23:00:20 +0900 (ebc691e7b)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2009-2016 Brazil
+  Copyright(C) 2009-2017 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -87,6 +87,8 @@ typedef struct {
   uint32_t unichar;
   uint32_t values_size;
   uint32_t nrecords;
+  uint32_t n_record_errors;
+  uint32_t n_column_errors;
   grn_loader_stat stat;
   grn_content_type input_type;
   grn_loader_columns_status columns_status;

  Modified: lib/load.c (+8 -0)
===================================================================
--- lib/load.c    2017-12-04 22:44:18 +0900 (aef15ffaf)
+++ lib/load.c    2017-12-04 23:00:20 +0900 (4f90dc9c3)
@@ -489,6 +489,7 @@ bracket_close(grn_ctx *ctx, grn_loader *loader)
       report_set_column_value_failure(ctx, key_value,
                                       column_name, column_name_size,
                                       value);
+      loader->n_column_errors++;
       ERRCLR(ctx);
     }
     cols++;
@@ -501,6 +502,9 @@ bracket_close(grn_ctx *ctx, grn_loader *loader)
   loader->nrecords++;
 exit:
   if (is_record_load) {
+    if (ctx->rc != GRN_SUCCESS) {
+      loader->n_record_errors++;
+    }
     if (loader->output_ids) {
       GRN_UINT32_PUT(ctx, &(loader->ids), id);
     }
@@ -656,6 +660,7 @@ brace_close(grn_ctx *ctx, grn_loader *loader)
         grn_loader_save_error(ctx, loader);
         report_set_column_value_failure(ctx, key_value,
                                         name, name_size, value);
+        loader->n_column_errors++;
         ERRCLR(ctx);
       }
       grn_obj_unlink(ctx, col);
@@ -668,6 +673,9 @@ brace_close(grn_ctx *ctx, grn_loader *loader)
   }
   loader->nrecords++;
 exit:
+  if (ctx->rc != GRN_SUCCESS) {
+    loader->n_record_errors++;
+  }
   if (loader->output_ids) {
     GRN_UINT32_PUT(ctx, &(loader->ids), id);
   }

  Modified: lib/proc.c (+6 -0)
===================================================================
--- lib/proc.c    2017-12-04 22:44:18 +0900 (4172f0dde)
+++ lib/proc.c    2017-12-04 23:00:20 +0900 (d92a5f16e)
@@ -183,6 +183,12 @@ proc_load(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
     GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_SIZE,
                   ":", "load(%d)",
                   ctx->impl->loader.nrecords);
+    GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_SIZE,
+                  ":", "record_error(%d)",
+                  ctx->impl->loader.n_record_errors);
+    GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_SIZE,
+                  ":", "column_error(%d)",
+                  ctx->impl->loader.n_column_errors);
     if (grn_ctx_get_command_version(ctx) >= GRN_COMMAND_VERSION_3) {
       int n_elements = 1;
       if (ctx->impl->loader.output_ids) {

  Modified: test/command/suite/load/command_version/3/query_log.expected (+17 -6)
===================================================================
--- test/command/suite/load/command_version/3/query_log.expected    2017-12-04 22:44:18 +0900 (385623079)
+++ test/command/suite/load/command_version/3/query_log.expected    2017-12-04 23:00:20 +0900 (16ca39f4f)
@@ -1,10 +1,15 @@
 table_create Numbers TABLE_PAT_KEY Int32
 [[0,0.0,0.0],true]
+column_create Numbers value1 COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
+column_create Numbers value2 COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
 load --table Numbers --command_version 3
 [
-{"_key": 1},
+{"_key": 1, "value1": 1, "value2": 2},
 {"_key": "string"},
-{"_key": 2}
+{"_key": 2, "value1": "string1", "value2": "string2"},
+{"_key": 3}
 ]
 {
   "header": {
@@ -12,17 +17,23 @@ load --table Numbers --command_version 3
     "start_time": 0.0,
     "elapsed_time": 0.0,
     "error": {
-      "message": "<Numbers>: failed to cast to <Int32>: <\"string\">",
-      "function": "grn_table_add_by_key",
+      "message": "<Numbers.value2>: failed to cast to <Int32>: <\"string2\">",
+      "function": "grn_obj_set_value_column_fix_size",
       "file": "db.c",
       "line": 0
     }
   },
   "body": {
-    "n_loaded_records": 2
+    "n_loaded_records": 3
   }
 }
 #|e| <Numbers>: failed to cast to <Int32>: <"string">
+#|e| <Numbers.value1>: failed to cast to <Int32>: <"string1">
+#|e| [table][load] failed to set column value: <Numbers.value1>: failed to cast to <Int32>: <"string1">: key: <2>, column: <value1>, value: <"string1">
+#|e| <Numbers.value2>: failed to cast to <Int32>: <"string2">
+#|e| [table][load] failed to set column value: <Numbers.value2>: failed to cast to <Int32>: <"string2">: key: <2>, column: <value2>, value: <"string2">
 #>load --command_version "3" --table "Numbers"
-#:000000000000000 load(2)
+#:000000000000000 load(3)
+#:000000000000000 record_error(1)
+#:000000000000000 column_error(2)
 #<000000000000000 rc=-22

  Modified: test/command/suite/load/command_version/3/query_log.test (+5 -2)
===================================================================
--- test/command/suite/load/command_version/3/query_log.test    2017-12-04 22:44:18 +0900 (6af0f92bc)
+++ test/command/suite/load/command_version/3/query_log.test    2017-12-04 23:00:20 +0900 (d5e025f8e)
@@ -1,10 +1,13 @@
 table_create Numbers TABLE_PAT_KEY Int32
+column_create Numbers value1 COLUMN_SCALAR Int32
+column_create Numbers value2 COLUMN_SCALAR Int32
 
 #@collect-query-log true
 load --table Numbers --command_version 3
 [
-{"_key": 1},
+{"_key": 1, "value1": 1, "value2": 2},
 {"_key": "string"},
-{"_key": 2}
+{"_key": 2, "value1": "string1", "value2": "string2"},
+{"_key": 3}
 ]
 #@collect-query-log false

  Modified: test/command/suite/load/query_log.expected (+25 -4)
===================================================================
--- test/command/suite/load/query_log.expected    2017-12-04 22:44:18 +0900 (9aceee035)
+++ test/command/suite/load/query_log.expected    2017-12-04 23:00:20 +0900 (26a802d47)
@@ -1,13 +1,34 @@
 table_create Numbers TABLE_PAT_KEY Int32
 [[0,0.0,0.0],true]
+column_create Numbers value1 COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
+column_create Numbers value2 COLUMN_SCALAR Int32
+[[0,0.0,0.0],true]
 load --table Numbers
 [
-{"_key": 1},
+{"_key": 1, "value1": 1, "value2": 2},
 {"_key": "string"},
-{"_key": 2}
+{"_key": 2, "value1": "string1", "value2": "string2"},
+{"_key": 3}
+]
+[
+  [
+    [
+      -22,
+      0.0,
+      0.0
+    ],
+    "<Numbers.value2>: failed to cast to <Int32>: <\"string2\">"
+  ],
+  3
 ]
-[[[-22,0.0,0.0],"<Numbers>: failed to cast to <Int32>: <\"string\">"],2]
 #|e| <Numbers>: failed to cast to <Int32>: <"string">
+#|e| <Numbers.value1>: failed to cast to <Int32>: <"string1">
+#|e| [table][load] failed to set column value: <Numbers.value1>: failed to cast to <Int32>: <"string1">: key: <2>, column: <value1>, value: <"string1">
+#|e| <Numbers.value2>: failed to cast to <Int32>: <"string2">
+#|e| [table][load] failed to set column value: <Numbers.value2>: failed to cast to <Int32>: <"string2">: key: <2>, column: <value2>, value: <"string2">
 #>load --table "Numbers"
-#:000000000000000 load(2)
+#:000000000000000 load(3)
+#:000000000000000 record_error(1)
+#:000000000000000 column_error(2)
 #<000000000000000 rc=-22

  Modified: test/command/suite/load/query_log.test (+5 -2)
===================================================================
--- test/command/suite/load/query_log.test    2017-12-04 22:44:18 +0900 (b61d644b7)
+++ test/command/suite/load/query_log.test    2017-12-04 23:00:20 +0900 (7be217885)
@@ -1,10 +1,13 @@
 table_create Numbers TABLE_PAT_KEY Int32
+column_create Numbers value1 COLUMN_SCALAR Int32
+column_create Numbers value2 COLUMN_SCALAR Int32
 
 #@collect-query-log true
 load --table Numbers
 [
-{"_key": 1},
+{"_key": 1, "value1": 1, "value2": 2},
 {"_key": "string"},
-{"_key": 2}
+{"_key": 2, "value1": "string1", "value2": "string2"},
+{"_key": 3}
 ]
 #@collect-query-log false
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171204/5294d012/attachment-0001.htm 



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