[Groonga-commit] ranguba/rroonga at adc99d0 [master] Bind grn_expr_dump_plan()

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Nov 3 15:53:10 JST 2014


Kouhei Sutou	2014-11-03 15:53:10 +0900 (Mon, 03 Nov 2014)

  New Revision: adc99d03a7d7200ad00278176d2c8f730a742d30
  https://github.com/ranguba/rroonga/commit/adc99d03a7d7200ad00278176d2c8f730a742d30

  Message:
    Bind grn_expr_dump_plan()
    
    It is defined since Groonga 4.0.8 that is not released yet.
    We should remove grn_expr_dump_plan() availability check after Groonga
    4.0.8 is released.
    
    I want to use it in Groonga's test.

  Modified files:
    ext/groonga/extconf.rb
    ext/groonga/rb-grn-expression.c

  Modified: ext/groonga/extconf.rb (+3 -0)
===================================================================
--- ext/groonga/extconf.rb    2014-11-02 18:53:17 +0900 (323eef8)
+++ ext/groonga/extconf.rb    2014-11-03 15:53:10 +0900 (713bf81)
@@ -283,6 +283,9 @@ have_func("rb_sym2str", "ruby.h")
 have_func("rb_to_symbol", "ruby.h")
 have_type("enum ruby_value_type", "ruby.h")
 
+# TODO: Remove me after Groogna 4.0.8 is released.
+have_func("grn_expr_dump_plan", "groonga.h")
+
 checking_for(checking_message("--enable-debug-log option")) do
   enable_debug_log = enable_config("debug-log", false)
   if enable_debug_log

  Modified: ext/groonga/rb-grn-expression.c (+33 -0)
===================================================================
--- ext/groonga/rb-grn-expression.c    2014-11-02 18:53:17 +0900 (21f94b4)
+++ ext/groonga/rb-grn-expression.c    2014-11-03 15:53:10 +0900 (5ddd6ac)
@@ -495,6 +495,37 @@ rb_grn_expression_compile (VALUE self)
 }
 
 /*
+ * Dump execution plan of the `expression` in string.
+ *
+ * @overload dump_plan
+ * @since 4.0.8
+ */
+static VALUE
+rb_grn_expression_dump_plan (VALUE self)
+{
+/* TODO: Remove me after Groogna 4.0.8 is released. */
+#ifdef HAVE_GRN_EXPR_DUMP_PLAN
+    grn_ctx *context = NULL;
+    grn_obj *expression;
+    grn_obj dumped_plan;
+    VALUE rb_dumped_plan;
+
+    rb_grn_expression_deconstruct(SELF(self), &expression, &context,
+                                  NULL, NULL,
+                                  NULL, NULL, NULL);
+
+    GRN_TEXT_INIT(&dumped_plan, 0);
+    grn_expr_dump_plan(context, expression, &dumped_plan);
+    rb_dumped_plan = GRNBULK2RVAL(context, &dumped_plan, NULL, self);
+    grn_obj_unlink(context, &dumped_plan);
+
+    return rb_dumped_plan;
+#else
+    return rb_str_new2("");
+#endif
+}
+
+/*
  * _expression_ で使用可能な変数のうち、名前が _name_
  * または _offset_ 番目に {Expression#append_object}
  * された変数の値を返す。
@@ -783,6 +814,8 @@ rb_grn_init_expression (VALUE mGrn)
                      rb_grn_expression_execute, 0);
     rb_define_method(rb_cGrnExpression, "compile",
                      rb_grn_expression_compile, 0);
+    rb_define_method(rb_cGrnExpression, "dump_plan",
+                     rb_grn_expression_dump_plan, 0);
 
     rb_define_method(rb_cGrnExpression, "[]",
                      rb_grn_expression_array_reference, 1);
-------------- next part --------------
HTML����������������������������...
Download 



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