Commit eace0e22 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:4635] merging fractal tree and handlerton code to main

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@41502 c7de825b-a66e-492c-adef-691d508d4ae1
parent 71e3a2b3
...@@ -6140,12 +6140,64 @@ int toku_dbt_up(DB*, ...@@ -6140,12 +6140,64 @@ int toku_dbt_up(DB*,
return 0; return 0;
} }
static inline enum row_type
compression_method_to_row_type(enum toku_compression_method method)
{
switch (method) {
case TOKU_NO_COMPRESSION:
return ROW_TYPE_TOKU_UNCOMPRESSED;
case TOKU_ZLIB_METHOD:
return ROW_TYPE_TOKU_ZLIB;
case TOKU_QUICKLZ_METHOD:
return ROW_TYPE_TOKU_QUICKLZ;
case TOKU_LZMA_METHOD:
return ROW_TYPE_TOKU_LZMA;
case TOKU_FAST_COMPRESSION_METHOD:
return ROW_TYPE_TOKU_FAST;
case TOKU_SMALL_COMPRESSION_METHOD:
return ROW_TYPE_TOKU_SMALL;
default:
assert(false);
}
}
enum row_type
ha_tokudb::get_row_type(void)
{
enum toku_compression_method method;
int r = share->file->get_compression_method(share->file, &method);
assert(r == 0);
return compression_method_to_row_type(method);
}
static inline enum toku_compression_method
row_type_to_compression_method(enum row_type type)
{
switch (type) {
case ROW_TYPE_TOKU_UNCOMPRESSED:
return TOKU_NO_COMPRESSION;
case ROW_TYPE_TOKU_ZLIB:
return TOKU_ZLIB_METHOD;
case ROW_TYPE_TOKU_QUICKLZ:
return TOKU_QUICKLZ_METHOD;
case ROW_TYPE_TOKU_LZMA:
return TOKU_LZMA_METHOD;
case ROW_TYPE_TOKU_FAST:
return TOKU_FAST_COMPRESSION_METHOD;
case ROW_TYPE_TOKU_SMALL:
return TOKU_SMALL_COMPRESSION_METHOD;
default:
assert(false);
}
}
static int create_sub_table( static int create_sub_table(
const char *table_name, const char *table_name,
DBT* row_descriptor, DBT* row_descriptor,
DB_TXN* txn, DB_TXN* txn,
uint32_t block_size, uint32_t block_size,
uint32_t read_block_size, uint32_t read_block_size,
enum row_type row_type,
bool is_hot_index bool is_hot_index
) )
{ {
...@@ -6185,6 +6237,15 @@ static int create_sub_table( ...@@ -6185,6 +6237,15 @@ static int create_sub_table(
goto exit; goto exit;
} }
{
enum toku_compression_method method = row_type_to_compression_method(row_type);
error = file->set_compression_method(file, method);
if (error != 0) {
DBUG_PRINT("error", ("Got error: %d when setting compression type %u for table '%s'", error, method, table_name));
goto exit;
}
}
error = file->change_descriptor(file, txn, row_descriptor, (is_hot_index ? DB_IS_HOT_INDEX : 0)); error = file->change_descriptor(file, txn, row_descriptor, (is_hot_index ? DB_IS_HOT_INDEX : 0));
if (error) { if (error) {
DBUG_PRINT("error", ("Got error: %d when setting row descriptor for table '%s'", error, table_name)); DBUG_PRINT("error", ("Got error: %d when setting row descriptor for table '%s'", error, table_name));
...@@ -6407,7 +6468,7 @@ int ha_tokudb::create_secondary_dictionary( ...@@ -6407,7 +6468,7 @@ int ha_tokudb::create_secondary_dictionary(
} }
read_block_size = get_tokudb_read_block_size(thd); read_block_size = get_tokudb_read_block_size(thd);
error = create_sub_table(newname, &row_descriptor, txn, block_size, read_block_size, is_hot_index); error = create_sub_table(newname, &row_descriptor, txn, block_size, read_block_size, form->s->row_type, is_hot_index);
cleanup: cleanup:
my_free(newname, MYF(MY_ALLOW_ZERO_PTR)); my_free(newname, MYF(MY_ALLOW_ZERO_PTR));
my_free(row_desc_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(row_desc_buff, MYF(MY_ALLOW_ZERO_PTR));
...@@ -6503,13 +6564,34 @@ int ha_tokudb::create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn ...@@ -6503,13 +6564,34 @@ int ha_tokudb::create_main_dictionary(const char* name, TABLE* form, DB_TXN* txn
read_block_size = get_tokudb_read_block_size(thd); read_block_size = get_tokudb_read_block_size(thd);
/* Create the main table that will hold the real rows */ /* Create the main table that will hold the real rows */
error = create_sub_table(newname, &row_descriptor, txn, block_size, read_block_size, false); error = create_sub_table(newname, &row_descriptor, txn, block_size, read_block_size, form->s->row_type, false);
cleanup: cleanup:
my_free(newname, MYF(MY_ALLOW_ZERO_PTR)); my_free(newname, MYF(MY_ALLOW_ZERO_PTR));
my_free(row_desc_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(row_desc_buff, MYF(MY_ALLOW_ZERO_PTR));
return error; return error;
} }
static inline enum row_type
row_format_to_row_type(srv_row_format_t row_format)
{
switch (row_format) {
case SRV_ROW_FORMAT_UNCOMPRESSED:
return ROW_TYPE_TOKU_UNCOMPRESSED;
case SRV_ROW_FORMAT_ZLIB:
return ROW_TYPE_TOKU_ZLIB;
case SRV_ROW_FORMAT_QUICKLZ:
return ROW_TYPE_TOKU_QUICKLZ;
case SRV_ROW_FORMAT_LZMA:
return ROW_TYPE_TOKU_LZMA;
case SRV_ROW_FORMAT_FAST:
return ROW_TYPE_TOKU_FAST;
case SRV_ROW_FORMAT_SMALL:
return ROW_TYPE_TOKU_SMALL;
default:
assert(false);
}
}
// //
// Creates a new table // Creates a new table
// Parameters: // Parameters:
...@@ -6544,7 +6626,12 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -6544,7 +6626,12 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
error = 0; error = 0;
goto cleanup; goto cleanup;
} }
if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) {
form->s->row_type = create_info->row_type;
} else {
form->s->row_type = row_format_to_row_type(get_row_format(thd));
}
newname = (char *)my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME)); newname = (char *)my_malloc(get_max_dict_name_path_length(name),MYF(MY_WME));
if (newname == NULL){ error = ENOMEM; goto cleanup;} if (newname == NULL){ error = ENOMEM; goto cleanup;}
......
...@@ -656,6 +656,8 @@ public: ...@@ -656,6 +656,8 @@ public:
THD* thd THD* thd
); );
enum row_type get_row_type();
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);
......
...@@ -174,6 +174,34 @@ static MYSQL_THDVAR_BOOL(checkpoint_lock, ...@@ -174,6 +174,34 @@ static MYSQL_THDVAR_BOOL(checkpoint_lock,
FALSE FALSE
); );
static const char *tokudb_row_format_names[] = {
"tokudb_uncompressed",
"tokudb_zlib",
"tokudb_quicklz",
"tokudb_lzma",
"tokudb_fast",
"tokudb_small",
NullS
};
static TYPELIB tokudb_row_format_typelib = {
array_elements(tokudb_row_format_names) - 1,
"tokudb_row_format_typelib",
tokudb_row_format_names,
NULL
};
static MYSQL_THDVAR_ENUM(row_format, PLUGIN_VAR_NOCMDARG,
"Specifies the compression method for a table during this session. "
"Possible values are TOKUDB_UNCOMPRESSED, TOKUDB_ZLIB, TOKUDB_QUICKLZ, "
"TOKUDB_LZMA, TOKUDB_FAST (default), and TOKUDB_SMALL",
NULL, NULL, SRV_ROW_FORMAT_FAST, &tokudb_row_format_typelib);
srv_row_format_t get_row_format(THD *thd)
{
return (srv_row_format_t) THDVAR(thd, row_format);
}
static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer); static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, const char *buffer);
static void tokudb_cleanup_log_files(void); static void tokudb_cleanup_log_files(void);
static int tokudb_end(handlerton * hton, ha_panic_function type); static int tokudb_end(handlerton * hton, ha_panic_function type);
...@@ -1487,6 +1515,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1487,6 +1515,7 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
MYSQL_SYSVAR(block_size), MYSQL_SYSVAR(block_size),
MYSQL_SYSVAR(read_block_size), MYSQL_SYSVAR(read_block_size),
MYSQL_SYSVAR(read_buf_size), MYSQL_SYSVAR(read_buf_size),
MYSQL_SYSVAR(row_format),
NULL NULL
}; };
......
...@@ -9,6 +9,16 @@ extern handlerton *tokudb_hton; ...@@ -9,6 +9,16 @@ extern handlerton *tokudb_hton;
extern DB_ENV *db_env; extern DB_ENV *db_env;
extern DB *metadata_db; extern DB *metadata_db;
enum srv_row_format_enum {
SRV_ROW_FORMAT_UNCOMPRESSED = 0,
SRV_ROW_FORMAT_ZLIB = 1,
SRV_ROW_FORMAT_QUICKLZ = 2,
SRV_ROW_FORMAT_LZMA = 3,
SRV_ROW_FORMAT_FAST = 4,
SRV_ROW_FORMAT_SMALL = 5
};
typedef enum srv_row_format_enum srv_row_format_t;
// thread variables // thread variables
uint get_pk_insert_mode(THD* thd); uint get_pk_insert_mode(THD* thd);
bool get_load_save_space(THD* thd); bool get_load_save_space(THD* thd);
...@@ -20,10 +30,12 @@ bool get_log_client_errors(THD* thd); ...@@ -20,10 +30,12 @@ bool get_log_client_errors(THD* thd);
uint get_tokudb_block_size(THD* thd); uint get_tokudb_block_size(THD* thd);
uint get_tokudb_read_block_size(THD* thd); uint get_tokudb_read_block_size(THD* thd);
uint get_tokudb_read_buf_size(THD* thd); uint get_tokudb_read_buf_size(THD* thd);
srv_row_format_t get_row_format(THD *thd);
extern HASH tokudb_open_tables; extern HASH tokudb_open_tables;
extern pthread_mutex_t tokudb_mutex; extern pthread_mutex_t tokudb_mutex;
extern pthread_mutex_t tokudb_meta_mutex; extern pthread_mutex_t tokudb_meta_mutex;
extern u_int32_t tokudb_write_status_frequency; extern u_int32_t tokudb_write_status_frequency;
extern u_int32_t tokudb_read_status_frequency; extern u_int32_t tokudb_read_status_frequency;
#endif //#ifdef _HATOKU_HTON #endif //#ifdef _HATOKU_HTON
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