This commit is contained in:
Evgeniy Gatov 2014-10-21 18:03:25 +04:00
commit d36b86e11d
2 changed files with 25 additions and 3 deletions

View File

@ -697,6 +697,17 @@ void ExpressionAnalyzer::makeExplicitSet(ASTFunction * node, const Block & sampl
if (left_arg_tuple && left_arg_tuple->name == "tuple")
{
for (const auto & arg : left_arg_tuple->arguments->children)
{
const auto & data_type = sample_block.getByName(arg->getColumnName()).type;
/// @note prevent crash in query: SELECT (1, [1]) in (1, 1)
if (const auto array = typeid_cast<const DataTypeArray * >(data_type.get()))
throw Exception("Incorrect element of tuple: " + array->getName(), ErrorCodes::INCORRECT_ELEMENT_OF_SET);
set_element_types.push_back(data_type);
}
for (ASTs::const_iterator it = left_arg_tuple->arguments->children.begin();
it != left_arg_tuple->arguments->children.end();
++it)

View File

@ -90,14 +90,15 @@ struct ZooKeeperArgs
config.keys(config_name, keys);
std::string node_key = "node";
std::vector<std::string> hosts_strings;
session_timeout_ms = DEFAULT_SESSION_TIMEOUT;
for (const auto & key : keys)
{
if (key == node_key || key.compare(0, node_key.size(), node_key) == 0)
{
if (hosts.size())
hosts += std::string(",");
hosts += config.getString(config_name + "." + key + ".host") + ":" + config.getString(config_name + "." + key + ".port");
hosts_strings.push_back(
config.getString(config_name + "." + key + ".host") + ":" + config.getString(config_name + "." + key + ".port"));
}
else if (key == "session_timeout_ms")
{
@ -105,6 +106,16 @@ struct ZooKeeperArgs
}
else throw KeeperException(std::string("Unknown key ") + key + " in config file");
}
/// перемешиваем порядок хостов, чтобы сделать нагрузку на zookeeper более равномерной
std::random_shuffle(hosts_strings.begin(), hosts_strings.end());
for (auto & host : hosts_strings)
{
if (hosts.size())
hosts += ",";
hosts += host;
}
}
std::string hosts;