Commit b59b1763 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1567

reintroduce new comparison function, mysql tests ran fine

git-svn-id: file:///svn/mysql/tokudb-engine/src@11029 c7de825b-a66e-492c-adef-691d508d4ae1
parent 27f62286
...@@ -517,7 +517,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i ...@@ -517,7 +517,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
*key_type = key_info->flags & HA_NOSAME ? DB_NOOVERWRITE : DB_YESOVERWRITE; *key_type = key_info->flags & HA_NOSAME ? DB_NOOVERWRITE : DB_YESOVERWRITE;
(*ptr)->app_private = (void *) (key_info); (*ptr)->app_private = (void *) (key_info);
(*ptr)->set_bt_compare(*ptr, tokudb_cmp_packed_key); (*ptr)->set_bt_compare(*ptr, tokudb_cmp_dbt_key);
DBUG_PRINT("info", ("Setting DB_DUP+DB_DUPSORT for key %s\n", key_info->name)); DBUG_PRINT("info", ("Setting DB_DUP+DB_DUPSORT for key %s\n", key_info->name));
// //
...@@ -525,7 +525,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i ...@@ -525,7 +525,7 @@ int ha_tokudb::open_secondary_table(DB** ptr, KEY* key_info, const char* name, i
// //
if (!(key_info->flags & HA_CLUSTERING)) { if (!(key_info->flags & HA_CLUSTERING)) {
(*ptr)->set_flags(*ptr, DB_DUP + DB_DUPSORT); (*ptr)->set_flags(*ptr, DB_DUP + DB_DUPSORT);
(*ptr)->set_dup_compare(*ptr, hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_primary_key); (*ptr)->set_dup_compare(*ptr, tokudb_cmp_dbt_data);
} }
(*ptr)->api_internal = share->file->app_private; (*ptr)->api_internal = share->file->app_private;
...@@ -676,7 +676,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -676,7 +676,7 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
else { else {
share->file->app_private = NULL; share->file->app_private = NULL;
} }
share->file->set_bt_compare(share->file, (hidden_primary_key ? tokudb_cmp_hidden_key : tokudb_cmp_packed_key)); share->file->set_bt_compare(share->file, tokudb_cmp_dbt_key);
make_name(newname, name, "main"); make_name(newname, name, "main");
fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME); fn_format(name_buff, newname, "", 0, MY_UNPACK_FILENAME);
...@@ -1628,27 +1628,15 @@ ha_rows ha_tokudb::estimate_rows_upper_bound() { ...@@ -1628,27 +1628,15 @@ ha_rows ha_tokudb::estimate_rows_upper_bound() {
// //
int ha_tokudb::cmp_ref(const uchar * ref1, const uchar * ref2) { int ha_tokudb::cmp_ref(const uchar * ref1, const uchar * ref2) {
int ret_val = 0; int ret_val = 0;
KEY *key_info = NULL;
if (hidden_primary_key) {
ret_val = tokudb_compare_two_hidden_keys(
(void *)ref1,
TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH,
(void *)ref2,
TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH
);
goto exit;
}
key_info = &table->key_info[table_share->primary_key];
ret_val = tokudb_compare_two_keys( ret_val = tokudb_compare_two_keys(
key_info,
ref1 + sizeof(u_int32_t), ref1 + sizeof(u_int32_t),
*(u_int32_t *)ref1, *(u_int32_t *)ref1,
ref2 + sizeof(u_int32_t), ref2 + sizeof(u_int32_t),
*(u_int32_t *)ref2, *(u_int32_t *)ref2,
(uchar *)share->file->descriptor.data + 4,
*(u_int32_t *)share->file->descriptor.data,
false false
); );
exit:
return ret_val; return ret_val;
} }
...@@ -2517,7 +2505,7 @@ typedef struct heavi_info { ...@@ -2517,7 +2505,7 @@ typedef struct heavi_info {
// //
static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) { static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h; HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key); int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return cmp>0 ? 1 : -1; return cmp>0 ? 1 : -1;
} }
...@@ -2547,7 +2535,7 @@ static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) { ...@@ -2547,7 +2535,7 @@ static int after_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
// //
static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *extra_h) { static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h; HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key); int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return cmp; return cmp;
} }
...@@ -2576,7 +2564,7 @@ static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *ext ...@@ -2576,7 +2564,7 @@ static int prefix_last_or_prev_heavi(const DBT *key, const DBT *value, void *ext
// //
static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) { static int before_key_heavi(const DBT *key, const DBT *value, void *extra_h) {
HEAVI_INFO info = (HEAVI_INFO)extra_h; HEAVI_INFO info = (HEAVI_INFO)extra_h;
int cmp = tokudb_prefix_cmp_packed_key(info->db, key, info->key); int cmp = tokudb_prefix_cmp_dbt_key(info->db, key, info->key);
return (cmp<0) ? -1 : 1; return (cmp<0) ? -1 : 1;
} }
...@@ -2626,7 +2614,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -2626,7 +2614,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) { if (error == 0) {
DBT orig_key; DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF); pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key)) { if (tokudb_prefix_cmp_dbt_key(share->key_file[active_index], &orig_key, &last_key)) {
error = DB_NOTFOUND; error = DB_NOTFOUND;
} }
} }
...@@ -2661,7 +2649,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -2661,7 +2649,7 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
if (error == 0) { if (error == 0) {
DBT orig_key; DBT orig_key;
pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF); pack_key(&orig_key, active_index, key_buff2, key, key_len, COL_NEG_INF);
if (tokudb_prefix_cmp_packed_key(share->key_file[active_index], &orig_key, &last_key) != 0) { if (tokudb_prefix_cmp_dbt_key(share->key_file[active_index], &orig_key, &last_key) != 0) {
error = cursor->c_get(cursor, &last_key, &row, DB_PREV); error = cursor->c_get(cursor, &last_key, &row, DB_PREV);
} }
} }
...@@ -3706,6 +3694,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -3706,6 +3694,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
char* newname = NULL; char* newname = NULL;
DBT row_descriptor; DBT row_descriptor;
uchar* row_desc_buff = NULL; uchar* row_desc_buff = NULL;
KEY* prim_key = NULL;
bzero(&row_descriptor, sizeof(row_descriptor)); bzero(&row_descriptor, sizeof(row_descriptor));
...@@ -3757,7 +3746,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -3757,7 +3746,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
// //
// setup the row descriptor // setup the row descriptor
// //
KEY* prim_key = (hidden_primary_key) ? NULL : &form->s->key_info[primary_key]; prim_key = (hidden_primary_key) ? NULL : &form->s->key_info[primary_key];
row_descriptor.data = row_desc_buff; row_descriptor.data = row_desc_buff;
row_descriptor.size = create_toku_descriptor( row_descriptor.size = create_toku_descriptor(
row_desc_buff, row_desc_buff,
......
This diff is collapsed.
...@@ -82,45 +82,23 @@ inline ulonglong hpk_char_to_num(uchar* val) { ...@@ -82,45 +82,23 @@ inline ulonglong hpk_char_to_num(uchar* val) {
return uint8korr(val); return uint8korr(val);
} }
inline int tokudb_compare_two_hidden_keys(
const void* new_key_data,
const u_int32_t new_key_size,
const void* saved_key_data,
const u_int32_t saved_key_size
);
int tokudb_compare_two_keys( int tokudb_compare_two_keys(
KEY *key,
const void* new_key_data, const void* new_key_data,
const u_int32_t new_key_size, const u_int32_t new_key_size,
const void* saved_key_data, const void* saved_key_data,
const u_int32_t saved_key_size, const u_int32_t saved_key_size,
const void* row_desc,
const u_int32_t row_desc_size,
bool cmp_prefix bool cmp_prefix
); );
int tokudb_cmp_hidden_key(
DB* file,
const DBT* new_key,
const DBT* saved_key
);
int tokudb_compare_two_clustered_keys(
KEY *key,
KEY* primary_key,
const DBT * new_key,
const DBT * saved_key
);
int tokudb_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb); int tokudb_cmp_dbt_data(DB *file, const DBT *keya, const DBT *keyb);
int tokudb_cmp_primary_key(DB *file, const DBT *keya, const DBT *keyb);
//TODO: QQQ Only do one direction for prefix. //TODO: QQQ Only do one direction for prefix.
int tokudb_prefix_cmp_packed_key(DB *file, const DBT *keya, const DBT *keyb); int tokudb_prefix_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
int create_toku_key_descriptor(KEY* key, uchar* buf); int create_toku_key_descriptor(KEY* key, uchar* buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment