[Groonga-commit] groonga/groonga at aff210c [master] Extract index report code

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Aug 18 23:41:25 JST 2015


Kouhei Sutou	2015-08-18 23:41:25 +0900 (Tue, 18 Aug 2015)

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

  Message:
    Extract index report code

  Added files:
    lib/grn_report.h
    lib/report.c
  Modified files:
    lib/expr.c
    lib/sources.am

  Modified: lib/expr.c (+5 -16)
===================================================================
--- lib/expr.c    2015-08-18 23:39:28 +0900 (c654469)
+++ lib/expr.c    2015-08-18 23:41:25 +0900 (da2e45f)
@@ -24,6 +24,7 @@
 #include "grn_expr.h"
 #include "grn_expr_code.h"
 #include "grn_util.h"
+#include "grn_report.h"
 #include "grn_mrb.h"
 #include "mrb/mrb_expr.h"
 
@@ -4798,22 +4799,10 @@ grn_table_select_sequential(grn_ctx *ctx, grn_obj *table, grn_obj *expr,
   GRN_OBJ_FIN(ctx, &score_buffer);
 }
 
-static const grn_log_level index_report_log_level = GRN_LOG_INFO;
-
 static inline void
 grn_table_select_index_report(grn_ctx *ctx, const char *tag, grn_obj *index)
 {
-  char index_name[GRN_TABLE_MAX_KEY_SIZE];
-  int index_name_size;
-
-  if (!grn_logger_pass(ctx, index_report_log_level)) {
-    return;
-  }
-
-  index_name_size = grn_obj_name(ctx, index, index_name, GRN_TABLE_MAX_KEY_SIZE);
-  GRN_LOG(ctx, index_report_log_level,
-          "[table][select][index]%s <%.*s>",
-          tag, index_name_size, index_name);
+  grn_report_index(ctx, "[table][select]", tag, index);
 }
 
 static inline grn_bool
@@ -4985,7 +4974,7 @@ grn_table_select_index_range_accessor(grn_ctx *ctx, grn_obj *table,
         section = index_datum.section;
       }
 
-      if (grn_logger_pass(ctx, index_report_log_level)) {
+      if (grn_logger_pass(ctx, GRN_REPORT_INDEX_LOG_LEVEL)) {
 #define TAG_BUFFER_SIZE 128
         char tag[TAG_BUFFER_SIZE];
         grn_snprintf(tag, TAG_BUFFER_SIZE, TAG_BUFFER_SIZE,
@@ -5386,7 +5375,7 @@ grn_table_select_index(grn_ctx *ctx, grn_obj *table, scan_info *si,
       if (grn_obj_is_selector_proc(ctx, si->args[0])) {
         grn_rc rc;
         grn_proc *proc = (grn_proc *)(si->args[0]);
-        if (grn_logger_pass(ctx, index_report_log_level)) {
+        if (grn_logger_pass(ctx, GRN_REPORT_INDEX_LOG_LEVEL)) {
           char proc_name[GRN_TABLE_MAX_KEY_SIZE];
           int proc_name_size;
           char tag[GRN_TABLE_MAX_KEY_SIZE];
@@ -5423,7 +5412,7 @@ grn_table_select_index(grn_ctx *ctx, grn_obj *table, scan_info *si,
       if (grn_obj_is_selector_proc(ctx, si->args[0])) {
         grn_rc rc;
         grn_proc *proc = (grn_proc *)(si->args[0]);
-        if (grn_logger_pass(ctx, index_report_log_level)) {
+        if (grn_logger_pass(ctx, GRN_REPORT_INDEX_LOG_LEVEL)) {
           char proc_name[GRN_TABLE_MAX_KEY_SIZE];
           int proc_name_size;
           char tag[GRN_TABLE_MAX_KEY_SIZE];

  Added: lib/grn_report.h (+39 -0) 100644
===================================================================
--- /dev/null
+++ lib/grn_report.h    2015-08-18 23:41:25 +0900 (ec2116d)
@@ -0,0 +1,39 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2015 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef GRN_REPORT_H
+#define GRN_REPORT_H
+
+#include "grn_ctx.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const grn_log_level GRN_REPORT_INDEX_LOG_LEVEL;
+
+void grn_report_index(grn_ctx *ctx,
+                      const char *action,
+                      const char *tag,
+                      grn_obj *index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRN_REPORT_H */

  Added: lib/report.c (+40 -0) 100644
===================================================================
--- /dev/null
+++ lib/report.c    2015-08-18 23:41:25 +0900 (3d134cc)
@@ -0,0 +1,40 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2015 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include "grn_report.h"
+
+const grn_log_level GRN_REPORT_INDEX_LOG_LEVEL = GRN_LOG_INFO;
+
+void
+grn_report_index(grn_ctx *ctx,
+                 const char *action,
+                 const char *tag,
+                 grn_obj *index)
+{
+  char index_name[GRN_TABLE_MAX_KEY_SIZE];
+  int index_name_size;
+
+  if (!grn_logger_pass(ctx, GRN_REPORT_INDEX_LOG_LEVEL)) {
+    return;
+  }
+
+  index_name_size = grn_obj_name(ctx, index, index_name, GRN_TABLE_MAX_KEY_SIZE);
+  GRN_LOG(ctx, GRN_REPORT_INDEX_LOG_LEVEL,
+          "%s[index]%s <%.*s>",
+          action, tag, index_name_size, index_name);
+}

  Modified: lib/sources.am (+2 -0)
===================================================================
--- lib/sources.am    2015-08-18 23:39:28 +0900 (a76fac3)
+++ lib/sources.am    2015-08-18 23:41:25 +0900 (8aea371)
@@ -47,6 +47,8 @@ libgroonga_la_SOURCES =				\
 	grn_plugin.h				\
 	proc.c					\
 	grn_proc.h				\
+	report.c				\
+	grn_report.h				\
 	request_canceler.c			\
 	grn_request_canceler.h			\
 	rset.c					\
-------------- next part --------------
HTML����������������������������...
Download 



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