[groonga-commit:634] groonga [groonga (trunk) r670] * use parse_level == 0 for column#match and

null at cozmixng.org null at cozmixng.org
Wed Sep 23 19:58:57 EDT 2009


retro	2009-09-24 08:58:56 +0900 (Thu, 24 Sep 2009)

  New Revision: 670

  Log:
    * use parse_level == 0 for column#match and
      parse_level == 2 for table#match by default.
  Modified files:
    groonga/trunk/ext/rb-grn-expression.c
    groonga/trunk/lib/groonga/expression-builder.rb


  Modified: groonga/trunk/ext/rb-grn-expression.c (+22 -4)
===================================================================
--- groonga/trunk/ext/rb-grn-expression.c	2009-09-22 18:06:02 +09:00 (rev 669)
+++ groonga/trunk/ext/rb-grn-expression.c	2009-09-24 08:58:56 -15:00 (rev 670)
@@ -215,14 +215,14 @@
     unsigned query_size = 0;
     int parse_level = 0;
     VALUE options, rb_query, rb_default_column, rb_default_operator;
-    VALUE rb_default_mode, rb_use_pragma;
+    VALUE rb_default_mode, rb_parser;
 
     rb_scan_args(argc, argv, "11", &rb_query, &options);
     rb_grn_scan_options(options,
                         "default_column", &rb_default_column,
                         "default_operator", &rb_default_operator,
                         "default_mode", &rb_default_mode,
-			"use_pragma", &rb_use_pragma,
+			"parser", &rb_parser,
                         NULL);
 
     query = StringValuePtr(rb_query);
@@ -237,8 +237,26 @@
 	default_mode = RVAL2GRNOPERATOR(rb_default_mode);
     if (!NIL_P(rb_default_operator))
 	default_operator = RVAL2GRNOPERATOR(rb_default_operator);
-    if (RVAL2CBOOL(rb_use_pragma))
+    if (NIL_P(rb_parser) ||
+	rb_grn_equal_option(rb_parser, "column") ||
+	rb_grn_equal_option(rb_parser, "column-query") ||
+	rb_grn_equal_option(rb_parser, "column_query")) {
+	parse_level = 0;
+    } else if (rb_grn_equal_option(rb_parser, "table") ||
+	       rb_grn_equal_option(rb_parser, "table-query") ||
+	       rb_grn_equal_option(rb_parser, "table_query")) {
+	parse_level = 2;
+    } else if (rb_grn_equal_option(rb_parser, "expression") ||
+	       rb_grn_equal_option(rb_parser, "language")) {
 	parse_level = 4;
+    } else {
+	rb_raise(rb_eArgError,
+		 "parser should be one of "
+		 "[nil, :column, :column_query, :table, :table_query, "
+		 ":expression, :language]: %s",
+		 rb_grn_inspect(rb_parser));
+    }
+
     rc = grn_expr_parse(context, expression, query, query_size,
 			default_column, default_mode, default_operator,
 			parse_level);
@@ -264,7 +282,7 @@
     rc = grn_expr_exec(context, expression, 0);
     rb_grn_context_check(context, self);
     rb_grn_rc_check(rc, self);
-    
+
     return Qnil;
 }
 

  Modified: groonga/trunk/lib/groonga/expression-builder.rb (+7 -3)
===================================================================
--- groonga/trunk/lib/groonga/expression-builder.rb	2009-09-22 18:06:02 +09:00 (rev 669)
+++ groonga/trunk/lib/groonga/expression-builder.rb	2009-09-24 08:58:56 -15:00 (rev 670)
@@ -185,7 +185,8 @@
       else
         options = options_or_default_column
       end
-      SubExpressionBuilder.new(query, options)
+      default_options = {:parser => :table}
+      SubExpressionBuilder.new(query, default_options.merge(options))
     end
   end
 
@@ -226,8 +227,11 @@
       GreaterEqualExpressionBuilder.new(@default_column, normalize(other))
     end
 
-    def match(query)
-      SubExpressionBuilder.new(query, :default_column => @default_column)
+    def match(query, options={})
+      default_options = {:parser => :table}
+      ensure_options = {:default_column => @default_column}
+      options = default_options.merge(options).merge(ensure_options)
+      SubExpressionBuilder.new(query, options)
     end
 
     private



More information about the groonga-commit mailing list