[Groonga-mysql-commit] mroonga/mroonga [master] multiple column key: get float value in caller

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 18日 (日) 18:16:48 JST


Kouhei Sutou	2012-03-18 18:16:48 +0900 (Sun, 18 Mar 2012)

  New Revision: bc8399fc00cc6af55cb3bdb3b4eb2694b72b1756

  Log:
    multiple column key: get float value in caller

  Modified files:
    ha_mroonga.cc
    ha_mroonga.h

  Modified: ha_mroonga.cc (+11 -9)
===================================================================
--- ha_mroonga.cc    2012-03-18 18:02:26 +0900 (b64405f)
+++ ha_mroonga.cc    2012-03-18 18:16:48 +0900 (26989f3)
@@ -8844,16 +8844,14 @@ int ha_mroonga::storage_encode_key(Field *field, const uchar *key,
   DBUG_RETURN(error);
 }
 
-uint ha_mroonga::storage_encode_multiple_column_key_float(const uchar *key,
+void ha_mroonga::storage_encode_multiple_column_key_float(float value,
+                                                          uint data_size,
                                                           uchar *buffer,
                                                           bool decode)
 {
   MRN_DBUG_ENTER_METHOD();
-  uint data_size = 4;
-  float float_value = 0.0;
-  float4get(float_value, key);
   int n_bits = (data_size * 8 - 1);
-  int int_value = *((int *)(&float_value));
+  int int_value = *((int *)(&value));
   if (!decode)
     int_value ^= ((int_value >> n_bits) | (1 << n_bits));
   mrn_byte_order_host_to_network(buffer, &int_value, data_size);
@@ -8862,7 +8860,7 @@ uint ha_mroonga::storage_encode_multiple_column_key_float(const uchar *key,
     *((int *)buffer) = int_value ^ (((int_value ^ (1 << n_bits)) >> n_bits) |
                                     (1 << n_bits));
   }
-  DBUG_RETURN(data_size);
+  DBUG_VOID_RETURN;
 }
 
 uint ha_mroonga::storage_encode_multiple_column_key_double(const uchar *key,
@@ -8944,9 +8942,13 @@ int ha_mroonga::storage_encode_multiple_column_key(KEY *key_info,
       break;
     case MYSQL_TYPE_FLOAT:
       data_type = TYPE_FLOAT;
-      data_size = storage_encode_multiple_column_key_float(current_key,
-                                                           current_buffer,
-                                                           decode);
+      data_size = 4;
+      {
+        float value;
+        float4get(value, current_key);
+        storage_encode_multiple_column_key_float(value, data_size,
+                                                 current_buffer, decode);
+      }
       break;
     case MYSQL_TYPE_DOUBLE:
       data_type = TYPE_DOUBLE;

  Modified: ha_mroonga.h (+2 -1)
===================================================================
--- ha_mroonga.h    2012-03-18 18:02:26 +0900 (848ffa7)
+++ ha_mroonga.h    2012-03-18 18:16:48 +0900 (97ffcd8)
@@ -533,7 +533,8 @@ private:
                                uchar *buf, uint *size);
 #endif
   int storage_encode_key(Field *field, const uchar *key, uchar *buf, uint *size);
-  uint storage_encode_multiple_column_key_float(const uchar *key,
+  void storage_encode_multiple_column_key_float(float vlaue,
+                                                uint data_size,
                                                 uchar *buffer,
                                                 bool decode);
   uint storage_encode_multiple_column_key_double(const uchar *key,




Groonga-mysql-commit メーリングリストの案内
Back to archive index