Commit 9baa3714 authored by Zardosht Kasheff's avatar Zardosht Kasheff

refs Tokutek/ft-index/#26 have ha_tokudb use new XXX_multiple API

parent a43124c1
...@@ -1263,11 +1263,12 @@ static inline int tokudb_generate_row( ...@@ -1263,11 +1263,12 @@ static inline int tokudb_generate_row(
static int generate_row_for_del( static int generate_row_for_del(
DB *dest_db, DB *dest_db,
DB *src_db, DB *src_db,
DBT *dest_key, DBT_ARRAY *dest_key_arrays,
const DBT *src_key, const DBT *src_key,
const DBT *src_val const DBT *src_val
) )
{ {
DBT* dest_key = &dest_key_arrays->dbts[0];
return tokudb_generate_row( return tokudb_generate_row(
dest_db, dest_db,
src_db, src_db,
...@@ -1282,12 +1283,14 @@ static int generate_row_for_del( ...@@ -1282,12 +1283,14 @@ static int generate_row_for_del(
static int generate_row_for_put( static int generate_row_for_put(
DB *dest_db, DB *dest_db,
DB *src_db, DB *src_db,
DBT *dest_key, DBT_ARRAY *dest_key_arrays,
DBT *dest_val, DBT_ARRAY *dest_val_arrays,
const DBT *src_key, const DBT *src_key,
const DBT *src_val const DBT *src_val
) )
{ {
DBT* dest_key = &dest_key_arrays->dbts[0];
DBT *dest_val = (dest_val_arrays == NULL) ? NULL : &dest_val_arrays->dbts[0];
return tokudb_generate_row( return tokudb_generate_row(
dest_db, dest_db,
src_db, src_db,
...@@ -1327,8 +1330,14 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, t ...@@ -1327,8 +1330,14 @@ ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, t
num_blob_bytes = 0; num_blob_bytes = 0;
delay_updating_ai_metadata = false; delay_updating_ai_metadata = false;
ai_metadata_update_required = false; ai_metadata_update_required = false;
memset(mult_key_dbt, 0, sizeof(mult_key_dbt)); memset(mult_key_dbt_array, 0, sizeof(mult_key_dbt_array));
memset(mult_rec_dbt, 0, sizeof(mult_rec_dbt)); memset(mult_rec_dbt_array, 0, sizeof(mult_rec_dbt_array));
for (uint32_t i = 0; i < sizeof(mult_key_dbt_array)/sizeof(mult_key_dbt_array[0]); i++) {
toku_dbt_array_init(&mult_key_dbt_array[i], 1);
}
for (uint32_t i = 0; i < sizeof(mult_rec_dbt_array)/sizeof(mult_rec_dbt_array[0]); i++) {
toku_dbt_array_init(&mult_rec_dbt_array[i], 1);
}
loader = NULL; loader = NULL;
abort_loader = false; abort_loader = false;
memset(&lc, 0, sizeof(lc)); memset(&lc, 0, sizeof(lc));
...@@ -1857,7 +1866,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1857,7 +1866,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
int error = 0; int error = 0;
int ret_val = 0; int ret_val = 0;
uint curr_num_DBs = 0;
transaction = NULL; transaction = NULL;
cursor = NULL; cursor = NULL;
...@@ -1875,7 +1883,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1875,7 +1883,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
else { else {
key_used_on_scan = primary_key; key_used_on_scan = primary_key;
} }
curr_num_DBs = table_share->keys + test(hidden_primary_key);
/* Need some extra memory in case of packed keys */ /* Need some extra memory in case of packed keys */
// the "+ 1" is for the first byte that states +/- infinity // the "+ 1" is for the first byte that states +/- infinity
...@@ -1918,14 +1925,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) { ...@@ -1918,14 +1925,6 @@ int ha_tokudb::open(const char *name, int mode, uint test_if_locked) {
goto exit; goto exit;
} }
for (uint32_t i = 0; i < sizeof(mult_key_dbt)/sizeof(mult_key_dbt[0]); i++) {
mult_key_dbt[i].flags = DB_DBT_REALLOC;
}
for (uint32_t i = 0; i < curr_num_DBs; i++) {
mult_rec_dbt[i].flags = DB_DBT_REALLOC;
}
/* Init shared structure */ /* Init shared structure */
pthread_mutex_lock(&tokudb_mutex); pthread_mutex_lock(&tokudb_mutex);
share = get_share(name, table_share); share = get_share(name, table_share);
...@@ -2256,17 +2255,11 @@ int ha_tokudb::__close() { ...@@ -2256,17 +2255,11 @@ int ha_tokudb::__close() {
my_free(blob_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(blob_buff, MYF(MY_ALLOW_ZERO_PTR));
my_free(alloc_ptr, MYF(MY_ALLOW_ZERO_PTR)); my_free(alloc_ptr, MYF(MY_ALLOW_ZERO_PTR));
my_free(range_query_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(range_query_buff, MYF(MY_ALLOW_ZERO_PTR));
for (uint32_t i = 0; i < sizeof(mult_rec_dbt)/sizeof(mult_rec_dbt[0]); i++) { for (uint32_t i = 0; i < sizeof(mult_key_dbt_array)/sizeof(mult_key_dbt_array[0]); i++) {
if (mult_rec_dbt[i].flags == DB_DBT_REALLOC && toku_dbt_array_destroy(&mult_key_dbt_array[i]);
mult_rec_dbt[i].data != NULL) {
free(mult_rec_dbt[i].data);
}
} }
for (uint32_t i = 0; i < sizeof(mult_key_dbt)/sizeof(mult_key_dbt[0]); i++) { for (uint32_t i = 0; i < sizeof(mult_rec_dbt_array)/sizeof(mult_rec_dbt_array[0]); i++) {
if (mult_key_dbt[i].flags == DB_DBT_REALLOC && toku_dbt_array_destroy(&mult_rec_dbt_array[i]);
mult_key_dbt[i].data != NULL) {
free(mult_key_dbt[i].data);
}
} }
rec_buff = NULL; rec_buff = NULL;
rec_update_buff = NULL; rec_update_buff = NULL;
...@@ -3937,13 +3930,13 @@ int ha_tokudb::insert_rows_to_dictionaries_mult(DBT* pk_key, DBT* pk_val, DB_TXN ...@@ -3937,13 +3930,13 @@ int ha_tokudb::insert_rows_to_dictionaries_mult(DBT* pk_key, DBT* pk_val, DB_TXN
// env->put_multiple(), except that // env->put_multiple(), except that
// we will just do a put() right away. // we will just do a put() right away.
error = tokudb_generate_row(db, src_db, error = tokudb_generate_row(db, src_db,
&mult_key_dbt[i], &mult_rec_dbt[i], &mult_key_dbt_array[i].dbts[0], &mult_rec_dbt_array[i].dbts[0],
pk_key, pk_val); pk_key, pk_val);
if (error != 0) { if (error != 0) {
goto out; goto out;
} }
error = db->put(db, txn, &mult_key_dbt[i], error = db->put(db, txn, &mult_key_dbt_array[i].dbts[0],
&mult_rec_dbt[i], flags); &mult_rec_dbt_array[i].dbts[0], flags);
} }
if (error != 0) { if (error != 0) {
goto out; goto out;
...@@ -3959,8 +3952,8 @@ int ha_tokudb::insert_rows_to_dictionaries_mult(DBT* pk_key, DBT* pk_val, DB_TXN ...@@ -3959,8 +3952,8 @@ int ha_tokudb::insert_rows_to_dictionaries_mult(DBT* pk_key, DBT* pk_val, DB_TXN
pk_val, pk_val,
curr_num_DBs, curr_num_DBs,
share->key_file, share->key_file,
mult_key_dbt, mult_key_dbt_array,
mult_rec_dbt, mult_rec_dbt_array,
mult_put_flags mult_put_flags
); );
} }
...@@ -4314,9 +4307,9 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -4314,9 +4307,9 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
share->key_file, share->key_file,
mult_put_flags, mult_put_flags,
2*curr_num_DBs, 2*curr_num_DBs,
mult_key_dbt, mult_key_dbt_array,
curr_num_DBs, curr_num_DBs,
mult_rec_dbt mult_rec_dbt_array
); );
if (error == DB_KEYEXIST) { if (error == DB_KEYEXIST) {
...@@ -4391,7 +4384,7 @@ int ha_tokudb::delete_row(const uchar * record) { ...@@ -4391,7 +4384,7 @@ int ha_tokudb::delete_row(const uchar * record) {
&row, &row,
curr_num_DBs, curr_num_DBs,
share->key_file, share->key_file,
mult_key_dbt, mult_key_dbt_array,
mult_del_flags mult_del_flags
); );
......
...@@ -281,8 +281,8 @@ class ha_tokudb : public handler { ...@@ -281,8 +281,8 @@ class ha_tokudb : public handler {
// //
// individual DBTs for each index // individual DBTs for each index
// //
DBT mult_key_dbt[2*(MAX_KEY + 1)]; DBT_ARRAY mult_key_dbt_array[2*(MAX_KEY + 1)];
DBT mult_rec_dbt[MAX_KEY + 1]; DBT_ARRAY mult_rec_dbt_array[MAX_KEY + 1];
uint32_t mult_put_flags[MAX_KEY + 1]; uint32_t mult_put_flags[MAX_KEY + 1];
uint32_t mult_del_flags[MAX_KEY + 1]; uint32_t mult_del_flags[MAX_KEY + 1];
uint32_t mult_dbt_flags[MAX_KEY + 1]; uint32_t mult_dbt_flags[MAX_KEY + 1];
......
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