Navigation Menu

Skip to content

Commit

Permalink
multiple column key: get float value in caller
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Mar 18, 2012
1 parent c8ff996 commit bc8399f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 11 additions & 9 deletions ha_mroonga.cc
Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ha_mroonga.h
Expand Up @@ -533,7 +533,8 @@ class ha_mroonga: public handler
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,
Expand Down

0 comments on commit bc8399f

Please sign in to comment.