[Groonga-mysql-commit] mroonga/mroonga at 91a902d [master] Extract convertable check for binary operation

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Dec 6 15:23:10 JST 2013


Kouhei Sutou	2013-12-06 15:23:10 +0900 (Fri, 06 Dec 2013)

  New Revision: 91a902d32be5abedc8d7282f4f50e44656d1e478
  https://github.com/mroonga/mroonga/commit/91a902d32be5abedc8d7282f4f50e44656d1e478

  Message:
    Extract convertable check for binary operation

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

  Modified: lib/mrn_condition_converter.cpp (+27 -14)
===================================================================
--- lib/mrn_condition_converter.cpp    2013-12-06 15:22:28 +0900 (9b8728a)
+++ lib/mrn_condition_converter.cpp    2013-12-06 15:23:10 +0900 (0eb8201)
@@ -126,20 +126,10 @@ namespace mrn {
           DBUG_RETURN(false);
         }
 
-        bool convertable = false;
-        switch (right_item->type()) {
-        case Item::STRING_ITEM:
-          if (func_item->functype() == Item_func::EQ_FUNC) {
-            Item_field *field_item = static_cast<Item_field *>(left_item);
-            convertable = is_convertable_string(field_item, right_item);
-          }
-          break;
-        case Item::INT_ITEM:
-          convertable = true;
-          break;
-        default:
-          break;
-        }
+        bool convertable =
+          is_convertable_binary_operation(static_cast<Item_field *>(left_item),
+                                          right_item,
+                                          func_item->functype());
         DBUG_RETURN(convertable);
       }
       break;
@@ -154,6 +144,29 @@ namespace mrn {
     DBUG_RETURN(true);
   }
 
+  bool ConditionConverter::is_convertable_binary_operation(
+    const Item_field *field_item,
+    const Item *value_item,
+    Item_func::Functype func_type) {
+    MRN_DBUG_ENTER_METHOD();
+
+    bool convertable = false;
+    switch (value_item->type()) {
+    case Item::STRING_ITEM:
+      if (func_type == Item_func::EQ_FUNC) {
+        convertable = is_convertable_string(field_item, value_item);
+      }
+      break;
+    case Item::INT_ITEM:
+      convertable = true;
+      break;
+    default:
+      break;
+    }
+
+    DBUG_RETURN(convertable);
+  }
+
   bool ConditionConverter::is_convertable_string(const Item_field *field_item,
                                                  const Item *string_item) {
     MRN_DBUG_ENTER_METHOD();

  Modified: lib/mrn_condition_converter.hpp (+3 -0)
===================================================================
--- lib/mrn_condition_converter.hpp    2013-12-06 15:22:28 +0900 (fce69e2)
+++ lib/mrn_condition_converter.hpp    2013-12-06 15:23:10 +0900 (584127e)
@@ -44,6 +44,9 @@ namespace mrn {
 
     bool is_convertable(const Item_cond *cond_item);
     bool is_convertable(const Item_func *func_item);
+    bool is_convertable_binary_operation(const Item_field *field_item,
+                                         const Item *value_item,
+                                         Item_func::Functype func_type);
     bool is_convertable_string(const Item_field *field_item,
                                const Item *string_item);
 
-------------- next part --------------
HTML����������������������������...
Download 



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