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

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Fri Aug 16 23:36:56 JST 2013


Kouhei Sutou	2013-08-16 23:36:56 +0900 (Fri, 16 Aug 2013)

  New Revision: 149e2882f77c10dbbc6ccb174ba4c44d05df842e
  https://github.com/mroonga/mroonga/commit/149e2882f77c10dbbc6ccb174ba4c44d05df842e

  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 (+18 -4)
===================================================================
--- lib/mrn_condition_converter.cpp    2013-08-16 23:29:11 +0900 (86c7c62)
+++ lib/mrn_condition_converter.cpp    2013-08-16 23:36:56 +0900 (6338730)
@@ -78,10 +78,7 @@ namespace mrn {
     if (left_item->type() == Item::FIELD_ITEM) {
       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_,
-                            GRN_OP_PUSH, 1);
+      append_const_item(right_item, expression);
       grn_expr_append_op(ctx_, expression, GRN_OP_EQUAL, 2);
       grn_expr_append_op(ctx_, expression, GRN_OP_AND, 2);
     }
@@ -105,4 +102,21 @@ namespace mrn {
 
     DBUG_VOID_RETURN;
   }
+
+  void ConditionConverter::append_const_item(Item *const_item,
+                                             grn_obj *expression) {
+    MRN_DBUG_ENTER_METHOD();
+
+    switch (const_item->type()) {
+    case Item::INT_ITEM:
+      grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
+      GRN_INT64_SET(ctx_, &value_, const_item->val_int());
+      break;
+    default:
+      break;
+    }
+    grn_expr_append_const(ctx_, expression, &value_, GRN_OP_PUSH, 1);
+
+    DBUG_VOID_RETURN;
+  }
 }

  Modified: lib/mrn_condition_converter.hpp (+4 -0)
===================================================================
--- lib/mrn_condition_converter.hpp    2013-08-16 23:29:11 +0900 (cb0d46a)
+++ lib/mrn_condition_converter.hpp    2013-08-16 23:36:56 +0900 (00b829f)
@@ -28,6 +28,9 @@ namespace mrn {
   public:
     ConditionConverter(grn_ctx *ctx);
     ~ConditionConverter();
+    // caller must check "where" can be convertable by
+    // mrn::Condition::is_comvertable(). This method doesn't validate
+    // "where".
     void convert(const Item *where, grn_obj *expression);
 
   private:
@@ -38,6 +41,7 @@ namespace mrn {
     void convert_equal(const Item_func *func_item, grn_obj *expression);
     void append_field_value(const Item_field *field_item,
                             grn_obj *expression);
+    void append_const_item(Item *const_item, grn_obj *expression);
   };
 }
 
-------------- next part --------------
HTML����������������������������...
ダウンロード 



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