PerformanceTest: use getMultiple*FromConfig, fix debug helpers (#915)

* PerformanceTest: use getMultiple*FromConfig, fix debug helpers

* Missing file
This commit is contained in:
proller 2017-06-22 21:56:40 +03:00 committed by alexey-milovidov
parent 990e62e579
commit 70d9fb06b4
7 changed files with 29 additions and 23 deletions

View File

@ -18,4 +18,14 @@ std::vector<std::string> getMultipleKeysFromConfig(Poco::Util::AbstractConfigura
}
return values;
}
std::vector<std::string> getMultipleValuesFromConfig(Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name)
{
std::vector<std::string> values;
for (const auto & key : DB::getMultipleKeysFromConfig(config, root, name))
values.emplace_back(config.getString(key));
return values;
}
}

View File

@ -13,4 +13,6 @@ namespace DB
{
/// get all internal key names for given key
std::vector<std::string> getMultipleKeysFromConfig(Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name);
/// Get all values for given key
std::vector<std::string> getMultipleValuesFromConfig(Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name);
}

View File

@ -21,7 +21,7 @@
#include <IO/WriteBufferFromFile.h>
#include <Interpreters/Settings.h>
#include <common/getMemoryAmount.h>
#include <Common/getMultipleKeysFromConfig.h>
#include <Poco/AutoPtr.h>
#include <Poco/Exception.h>
@ -857,15 +857,7 @@ private:
if (test_config->has("query"))
{
queries.push_back(test_config->getString("query"));
for (size_t i = 1; ; ++i)
{
std::string key = "query[" + std::to_string(i) + "]";
if (!test_config->has(key))
break;
queries.push_back(test_config->getString(key));
}
queries = DB::getMultipleValuesFromConfig(*test_config, "", "query");
}
if (test_config->has("query_file"))

View File

@ -439,11 +439,7 @@ int Server::main(const std::vector<std::string> & args)
std::vector<std::unique_ptr<Poco::Net::TCPServer>> servers;
std::vector<std::string> listen_hosts;
for (const auto & key : DB::getMultipleKeysFromConfig(config(), "", "listen_host"))
{
listen_hosts.emplace_back(config().getString(key));
}
std::vector<std::string> listen_hosts = DB::getMultipleValuesFromConfig(config(), "", "listen_host");
bool try_listen = false;
if (listen_hosts.empty())

View File

@ -27,6 +27,7 @@ add_library (common
src/exp10.cpp
src/JSON.cpp
src/getMemoryAmount.cpp
src/iostream_debug_helpers.cpp
include/common/ApplicationServerExt.h
include/common/Types.h
@ -43,6 +44,7 @@ add_library (common
include/common/strong_typedef.h
include/common/JSON.h
include/common/getMemoryAmount.h
include/common/iostream_debug_helpers.h
include/ext/bit_cast.h
include/ext/collection_cast.h

View File

@ -160,13 +160,7 @@ std::ostream & operator<<(std::ostream & stream, const std::experimental::option
}
#include <exception>
std::ostream & operator<<(std::ostream & stream, const std::exception & what)
{
stream << "exception{" << what.what() << "}";
return stream;
}
namespace std { class exception; }
std::ostream & operator<<(std::ostream & stream, const std::exception & what);
// TODO: add more types

View File

@ -0,0 +1,10 @@
#include "common/iostream_debug_helpers.h"
#include <exception>
std::ostream & operator<<(std::ostream & stream, const std::exception & what)
{
stream << "exception{" << what.what() << "}";
return stream;
}