[Groonga-mysql-commit] mroonga/mroonga at a95327e [master] Extract appending field value to expression code

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Fri Aug 16 23:29:11 JST 2013


Kouhei Sutou	2013-08-16 23:29:11 +0900 (Fri, 16 Aug 2013)

  New Revision: a95327e5489b35dc7edf59cb652d9b302b3e9367
  https://github.com/mroonga/mroonga/commit/a95327e5489b35dc7edf59cb652d9b302b3e9367

  Message:
    Extract appending field value to expression code

  Modified files:
    lib/mrn_condition_converter.cpp
    lib/mrn_condition_converter.hpp

  Modified: lib/mrn_condition_converter.cpp (+21 -11)
===================================================================
--- lib/mrn_condition_converter.cpp    2013-08-16 23:20:23 +0900 (8475db3)
+++ lib/mrn_condition_converter.cpp    2013-08-16 23:29:11 +0900 (86c7c62)
@@ -76,17 +76,8 @@ namespace mrn {
     Item *left_item = arguments[0];
     Item *right_item = arguments[1];
     if (left_item->type() == Item::FIELD_ITEM) {
-      GRN_BULK_REWIND(&column_name_);
-#ifdef MRN_ITEM_HAVE_ITEM_NAME
-      Item_name_string *name = &(left_item->item_name);
-      GRN_TEXT_PUT(ctx_, &column_name_,
-                   name->ptr(), name->length());
-#else
-      GRN_TEXT_PUTS(ctx_, &column_name_, left_item->name);
-#endif
-      grn_expr_append_const(ctx_, expression, &column_name_,
-                            GRN_OP_PUSH, 1);
-      grn_expr_append_op(ctx_, expression, GRN_OP_GET_VALUE, 1);
+      const Item_field *field_item = static_cast<const Item_field *>(left_item);
+      append_field_value(field_item, expression);
       grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
       GRN_INT64_SET(ctx_, &value_, right_item->val_int());
       grn_expr_append_const(ctx_, expression, &value_,
@@ -95,4 +86,23 @@ namespace mrn {
       grn_expr_append_op(ctx_, expression, GRN_OP_AND, 2);
     }
   }
+
+  void ConditionConverter::append_field_value(const Item_field *field_item,
+                                              grn_obj *expression) {
+    MRN_DBUG_ENTER_METHOD();
+
+    GRN_BULK_REWIND(&column_name_);
+#ifdef MRN_ITEM_HAVE_ITEM_NAME
+    Item_name_string *name = &(field_item->item_name);
+    GRN_TEXT_PUT(ctx_, &column_name_,
+                 name->ptr(), name->length());
+#else
+    GRN_TEXT_PUTS(ctx_, &column_name_, field_item->name);
+#endif
+    grn_expr_append_const(ctx_, expression, &column_name_,
+                          GRN_OP_PUSH, 1);
+    grn_expr_append_op(ctx_, expression, GRN_OP_GET_VALUE, 1);
+
+    DBUG_VOID_RETURN;
+  }
 }

  Modified: lib/mrn_condition_converter.hpp (+2 -0)
===================================================================
--- lib/mrn_condition_converter.hpp    2013-08-16 23:20:23 +0900 (629dad7)
+++ lib/mrn_condition_converter.hpp    2013-08-16 23:29:11 +0900 (cb0d46a)
@@ -36,6 +36,8 @@ namespace mrn {
     grn_obj value_;
 
     void convert_equal(const Item_func *func_item, grn_obj *expression);
+    void append_field_value(const Item_field *field_item,
+                            grn_obj *expression);
   };
 }
 
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-mysql-commit mailing list
アーカイブの一覧に戻る