Commit 009eceee authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #647

implement HA_READ_PREFIX_LAST

git-svn-id: file:///svn/mysql/tokudb-engine/src@6620 c7de825b-a66e-492c-adef-691d508d4ae1
parent 73547bc2
...@@ -983,6 +983,8 @@ static void smart_dbt_callback_rowread(DBT const *key, DBT const *row, void *co ...@@ -983,6 +983,8 @@ static void smart_dbt_callback_rowread(DBT const *key, DBT const *row, void *co
// Smart DBT callback function in c_getf_heavi, in case where we have a covering index, // Smart DBT callback function in c_getf_heavi, in case where we have a covering index,
// //
static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, void *context, int r_h) { static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, void *context, int r_h) {
SMART_DBT_INFO info = (SMART_DBT_INFO)context;
info->ha->heavi_ret_val = r_h;
smart_dbt_callback_keyread(key,row,context); smart_dbt_callback_keyread(key,row,context);
} }
...@@ -990,6 +992,8 @@ static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, vo ...@@ -990,6 +992,8 @@ static void smart_dbt_callback_keyread_heavi(DBT const *key, DBT const *row, vo
// Smart DBT callback function in c_getf_heavi, in case where we do NOT have a covering index // Smart DBT callback function in c_getf_heavi, in case where we do NOT have a covering index
// //
static void smart_dbt_callback_rowread_heavi(DBT const *key, DBT const *row, void *context, int r_h) { static void smart_dbt_callback_rowread_heavi(DBT const *key, DBT const *row, void *context, int r_h) {
SMART_DBT_INFO info = (SMART_DBT_INFO)context;
info->ha->heavi_ret_val = r_h;
smart_dbt_callback_rowread(key,row,context); smart_dbt_callback_rowread(key,row,context);
} }
...@@ -3086,9 +3090,10 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -3086,9 +3090,10 @@ 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_packed_key(share->key_file[active_index], &orig_key, &last_key)) {
error = DB_NOTFOUND; error = DB_NOTFOUND;
} }
}
break; break;
case HA_READ_AFTER_KEY: /* Find next rec. after key-record */ case HA_READ_AFTER_KEY: /* Find next rec. after key-record */
error = cursor->c_getf_heavi( error = cursor->c_getf_heavi(
...@@ -3116,9 +3121,10 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -3116,9 +3121,10 @@ 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_packed_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);
} }
}
else if (error == DB_NOTFOUND) else if (error == DB_NOTFOUND)
error = cursor->c_get(cursor, &last_key, &row, DB_LAST); error = cursor->c_get(cursor, &last_key, &row, DB_LAST);
break; break;
...@@ -3131,6 +3137,18 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_ ...@@ -3131,6 +3137,18 @@ int ha_tokudb::index_read(uchar * buf, const uchar * key, uint key_len, enum ha_
); );
do_read_row = false; do_read_row = false;
break; break;
case HA_READ_PREFIX_LAST:
error = cursor->c_getf_heavi(
cursor, 0,
key_read ? smart_dbt_callback_keyread_heavi : smart_dbt_callback_rowread_heavi, &info,
prefix_last_or_prev_heavi, &heavi_info,
-1
);
if (!error && heavi_ret_val != 0) {
error = DB_NOTFOUND;
}
do_read_row = false;
break;
default: default:
TOKUDB_TRACE("unsupported:%d\n", find_flag); TOKUDB_TRACE("unsupported:%d\n", find_flag);
error = HA_ERR_UNSUPPORTED; error = HA_ERR_UNSUPPORTED;
......
...@@ -338,6 +338,8 @@ class ha_tokudb : public handler { ...@@ -338,6 +338,8 @@ class ha_tokudb : public handler {
int read_row(uchar * buf, uint keynr, DBT const *row, DBT const *found_key); int read_row(uchar * buf, uint keynr, DBT const *row, DBT const *found_key);
void unpack_row(uchar * record, DBT const *row, DBT const *key); void unpack_row(uchar * record, DBT const *row, DBT const *key);
int heavi_ret_val;
private: private:
int read_full_row(uchar * buf); int read_full_row(uchar * buf);
int __close(int mutex_is_locked); int __close(int mutex_is_locked);
......
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