[Groonga-commit] groonga/groonga at ac92487 [master] sub_filter: log an event that pre filter is used

Back to archive index

Kouhei Sutou null+****@clear*****
Tue May 15 15:36:38 JST 2018


Kouhei Sutou	2018-05-15 15:36:38 +0900 (Tue, 15 May 2018)

  New Revision: ac92487a8fd3f565aae9897affea53b2ddbfd890
  https://github.com/groonga/groonga/commit/ac92487a8fd3f565aae9897affea53b2ddbfd890

  Message:
    sub_filter: log an event that pre filter is used

  Modified files:
    lib/grn_report.h
    lib/proc.c
    lib/report.c
    test/command/suite/select/function/sub_filter/column/vector/filtered.expected
    test/command/suite/select/function/sub_filter/column/vector/filtered.test

  Modified: lib/grn_report.h (+6 -1)
===================================================================
--- lib/grn_report.h    2018-05-15 15:32:24 +0900 (a8bd52fcd)
+++ lib/grn_report.h    2018-05-15 15:36:38 +0900 (abd5f2d33)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2015-2016 Brazil
+  Copyright(C) 2015-2018 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,11 @@ void grn_report_table(grn_ctx *ctx,
                       const char *tag,
                       grn_obj *table);
 
+void grn_report_column(grn_ctx *ctx,
+                       const char *action,
+                       const char *tag,
+                       grn_obj *column);
+
 #ifdef __cplusplus
 }
 #endif

  Modified: lib/proc.c (+6 -0)
===================================================================
--- lib/proc.c    2018-05-15 15:32:24 +0900 (f7fbe5b08)
+++ lib/proc.c    2018-05-15 15:36:38 +0900 (6f0d98abc)
@@ -27,6 +27,7 @@
 #include "grn_expr.h"
 #include "grn_cache.h"
 #include "grn_load.h"
+#include "grn_report.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -2141,6 +2142,11 @@ sub_filter_pre_filter(grn_ctx *ctx,
   } GRN_TABLE_EACH_END(ctx, cursor);
   GRN_OBJ_FIN(ctx, &values);
 
+  grn_report_column(ctx,
+                    "[sub_filter][pre-filter]",
+                    "",
+                    scope);
+
   return GRN_TRUE;
 }
 

  Modified: lib/report.c (+41 -1)
===================================================================
--- lib/report.c    2018-05-15 15:32:24 +0900 (b9e396e04)
+++ lib/report.c    2018-05-15 15:36:38 +0900 (9bea9e239)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2015-2016 Brazil
+  Copyright(C) 2015-2018 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -96,3 +96,43 @@ grn_report_table(grn_ctx *ctx,
           GRN_TEXT_VALUE(&description));
   GRN_OBJ_FIN(ctx, &description);
 }
+
+void
+grn_report_column(grn_ctx *ctx,
+                  const char *action,
+                  const char *tag,
+                  grn_obj *column)
+{
+  grn_obj description;
+  grn_obj *target;
+
+  if (!grn_logger_pass(ctx, GRN_REPORT_INDEX_LOG_LEVEL)) {
+    return;
+  }
+
+  GRN_TEXT_INIT(&description, 0);
+  for (target = column;
+       target;
+       target = grn_ctx_at(ctx, grn_obj_get_range(ctx, target))) {
+    char name[GRN_TABLE_MAX_KEY_SIZE];
+    int name_size;
+
+    name_size = grn_obj_name(ctx, target, name, GRN_TABLE_MAX_KEY_SIZE);
+    if (GRN_TEXT_LEN(&description) > 0) {
+      GRN_TEXT_PUTS(ctx, &description, " -> ");
+    }
+    if (name_size == 0) {
+      GRN_TEXT_PUTS(ctx, &description, "(temporary)");
+    } else {
+      GRN_TEXT_PUTS(ctx, &description, "<");
+      GRN_TEXT_PUT(ctx, &description, name, name_size);
+      GRN_TEXT_PUTS(ctx, &description, ">");
+    }
+  }
+  GRN_LOG(ctx, GRN_REPORT_INDEX_LOG_LEVEL,
+          "%s[column]%s %.*s",
+          action, tag,
+          (int)GRN_TEXT_LEN(&description),
+          GRN_TEXT_VALUE(&description));
+  GRN_OBJ_FIN(ctx, &description);
+}

  Modified: test/command/suite/select/function/sub_filter/column/vector/filtered.expected (+10 -0)
===================================================================
--- test/command/suite/select/function/sub_filter/column/vector/filtered.expected    2018-05-15 15:32:24 +0900 (c3ee255f5)
+++ test/command/suite/select/function/sub_filter/column/vector/filtered.expected    2018-05-15 15:36:38 +0900 (aed3acd44)
@@ -29,6 +29,8 @@ load --table Packages
 {"_key": "mroonga", "files": ["ha_mroonga.cc", "ha_mroonga.hpp"]}
 ]
 [[0,0.0,0.0],3]
+log_level --level info
+[[0,0.0,0.0],true]
 select Packages   --filter '_key == "rroonga" &&             sub_filter(files, "revision >= 10 && revision < 40")'   --output_columns '_key, files, files.revision'
 [
   [
@@ -69,3 +71,11 @@ select Packages   --filter '_key == "rroonga" &&             sub_filter(files, "
     ]
   ]
 ]
+#|i| [table][select][index][equal][accessor][key] <Packages>
+#|i| [table][select][index][selector][no-index][sub_filter] <Packages>
+#|i| [sub_filter][pre-filter][column] <Packages.files> -> <Files>
+#|i| [table][select][index][range] <Revisions.files_revision>
+#|i| [table][select][index][range] <Revisions.files_revision>
+#|i| [accessor][resolve][data-column][index] <Files.packages_files_index>
+log_level --level notice
+[[0,0.0,0.0],true]

  Modified: test/command/suite/select/function/sub_filter/column/vector/filtered.test (+4 -0)
===================================================================
--- test/command/suite/select/function/sub_filter/column/vector/filtered.test    2018-05-15 15:32:24 +0900 (c5cefefa1)
+++ test/command/suite/select/function/sub_filter/column/vector/filtered.test    2018-05-15 15:36:38 +0900 (763ac33cd)
@@ -26,7 +26,11 @@ load --table Packages
 {"_key": "mroonga", "files": ["ha_mroonga.cc", "ha_mroonga.hpp"]}
 ]
 
+#@add-important-log-levels info
+log_level --level info
 select Packages \
   --filter '_key == "rroonga" && \
             sub_filter(files, "revision >= 10 && revision < 40")' \
   --output_columns '_key, files, files.revision'
+log_level --level notice
+#@remove-important-log-levels info
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180515/c987d08f/attachment-0001.htm 



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