Commit 354d79cd authored by unknown's avatar unknown

generalized option for specifying ndb distribution

parent 3198d625
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
// options from from mysqld.cc // options from from mysqld.cc
extern my_bool opt_ndb_optimized_node_selection; extern my_bool opt_ndb_optimized_node_selection;
extern my_bool opt_ndb_linear_hash; extern enum ndb_distribution opt_ndb_distribution_id;
extern const char *opt_ndbcluster_connectstring; extern const char *opt_ndbcluster_connectstring;
// Default value for parallelism // Default value for parallelism
...@@ -7450,7 +7450,7 @@ uint ha_ndbcluster::set_up_partition_info(partition_info *part_info, ...@@ -7450,7 +7450,7 @@ uint ha_ndbcluster::set_up_partition_info(partition_info *part_info,
static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
{ {
NDBTAB::FragmentType ftype; NDBTAB::FragmentType ftype= NDBTAB::DistrKeyHash;
ushort node_group[MAX_PARTITIONS]; ushort node_group[MAX_PARTITIONS];
uint no_nodes= g_ndb_cluster_connection->no_db_nodes(), no_fragments, i; uint no_nodes= g_ndb_cluster_connection->no_db_nodes(), no_fragments, i;
DBUG_ENTER("ndb_set_fragmentation"); DBUG_ENTER("ndb_set_fragmentation");
...@@ -7481,10 +7481,14 @@ static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) ...@@ -7481,10 +7481,14 @@ static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
node_group[0]= 0; node_group[0]= 0;
for (i= 1; i < no_fragments; i++) for (i= 1; i < no_fragments; i++)
node_group[i]= UNDEF_NODEGROUP; node_group[i]= UNDEF_NODEGROUP;
if (opt_ndb_linear_hash) switch (opt_ndb_distribution_id)
{
case ND_KEYHASH:
break;
case ND_LINHASH:
ftype= NDBTAB::DistrKeyLin; ftype= NDBTAB::DistrKeyLin;
else break;
ftype= NDBTAB::DistrKeyHash; }
tab.setFragmentType(ftype); tab.setFragmentType(ftype);
tab.setNodeGroupIds(&node_group, no_fragments); tab.setNodeGroupIds(&node_group, no_fragments);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
...@@ -113,6 +113,8 @@ struct negated_function_mapping ...@@ -113,6 +113,8 @@ struct negated_function_mapping
NDB_FUNC_TYPE neg_fun; NDB_FUNC_TYPE neg_fun;
}; };
enum ndb_distribution { ND_KEYHASH= 0, ND_LINHASH= 1 };
/* /*
Define what functions can be negated in condition pushdown. Define what functions can be negated in condition pushdown.
Note, these HAVE to be in the same order as in definition enum Note, these HAVE to be in the same order as in definition enum
......
...@@ -362,7 +362,12 @@ my_bool opt_ndb_shm, opt_ndb_optimized_node_selection; ...@@ -362,7 +362,12 @@ my_bool opt_ndb_shm, opt_ndb_optimized_node_selection;
ulong opt_ndb_cache_check_time; ulong opt_ndb_cache_check_time;
const char *opt_ndb_mgmd; const char *opt_ndb_mgmd;
ulong opt_ndb_nodeid; ulong opt_ndb_nodeid;
bool opt_ndb_linear_hash;
const char *ndb_distribution_names[]= {"KEYHASH", "LINHASH", NullS};
TYPELIB ndb_distribution_typelib= { array_elements(ndb_distribution_names)-1,
"", ndb_distribution_names, NULL };
const char *opt_ndb_distribution= ndb_distribution_names[ND_KEYHASH];
enum ndb_distribution opt_ndb_distribution_id= ND_KEYHASH;
#endif #endif
my_bool opt_readonly, use_temp_pool, relay_log_purge; my_bool opt_readonly, use_temp_pool, relay_log_purge;
my_bool opt_sync_frm, opt_allow_suspicious_udfs; my_bool opt_sync_frm, opt_allow_suspicious_udfs;
...@@ -4879,16 +4884,11 @@ Disable with --skip-ndbcluster (will save memory).", ...@@ -4879,16 +4884,11 @@ Disable with --skip-ndbcluster (will save memory).",
(gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
(gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, 0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
{"ndb-use-linear-hash", OPT_NDB_LINEAR_HASH, {"ndb-distibution", OPT_NDB_DISTRIBUTION,
"Flag to indicate whether to use linear hash for default in new tables", "Default distribution for new tables in ndb",
(gptr*) &opt_ndb_linear_hash, (gptr*) &opt_ndb_distribution,
(gptr*) &opt_ndb_linear_hash, (gptr*) &opt_ndb_distribution,
0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"ndb_use_linear_hash", OPT_NDB_LINEAR_HASH,
"Flag to indicate whether to use linear hash for default in new tables",
(gptr*) &opt_ndb_linear_hash,
(gptr*) &opt_ndb_linear_hash,
0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
{"ndb-force-send", OPT_NDB_FORCE_SEND, {"ndb-force-send", OPT_NDB_FORCE_SEND,
"Force send of buffers to ndb immediately without waiting for " "Force send of buffers to ndb immediately without waiting for "
"other threads.", "other threads.",
...@@ -6674,6 +6674,20 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -6674,6 +6674,20 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_ndb_constrbuf[opt_ndb_constrbuf_len]= 0; opt_ndb_constrbuf[opt_ndb_constrbuf_len]= 0;
opt_ndbcluster_connectstring= opt_ndb_constrbuf; opt_ndbcluster_connectstring= opt_ndb_constrbuf;
break; break;
case OPT_NDB_DISTRIBUTION:
int id;
if ((id= find_type(argument, &ndb_distribution_typelib, 2)) <= 0)
{
fprintf(stderr,
"Unknown ndb distribution type: '%s' "
"(should be '%s' or '%s')\n",
argument,
ndb_distribution_names[ND_KEYHASH],
ndb_distribution_names[ND_LINHASH]);
exit(1);
}
opt_ndb_distribution_id= (enum ndb_distribution)(id-1);
break;
#endif #endif
case OPT_INNODB: case OPT_INNODB:
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
......
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