mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
dbms: improvement [#CONV-2944].
This commit is contained in:
parent
fe0dd1d0b2
commit
3fbd36fde9
@ -2,8 +2,6 @@
|
||||
|
||||
#include <Poco/UTF8Encoding.h>
|
||||
#include <Poco/Unicode.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/DataTypes/DataTypesNumberFixed.h>
|
||||
#include <DB/DataTypes/DataTypeString.h>
|
||||
#include <DB/DataTypes/DataTypeFixedString.h>
|
||||
|
@ -576,11 +576,17 @@ template <typename T>
|
||||
inline T parse(const char * data, size_t size)
|
||||
{
|
||||
T res;
|
||||
ReadBuffer buf(data, size, 0);
|
||||
ReadBuffer buf(const_cast<char *>(data), size, 0);
|
||||
readText(res, buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parse(const char * data)
|
||||
{
|
||||
return parse<T>(data, strlen(data));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parse(const String & s)
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <DB/Core/Field.h>
|
||||
|
||||
#include <statdaemons/Stopwatch.h>
|
||||
@ -44,7 +43,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
try
|
||||
{
|
||||
size_t n = argc == 2 ? Poco::NumberParser::parseUnsigned64(argv[1]) : 10000000;
|
||||
size_t n = argc == 2 ? DB::parse<UInt64>(argv[1]) : 10000000;
|
||||
|
||||
Stopwatch watch;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <Poco/ConsoleChannel.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromFileDescriptor.h>
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
|
||||
@ -28,7 +27,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
size_t n = argc == 2 ? Poco::NumberParser::parseUnsigned64(argv[1]) : 10ULL;
|
||||
size_t n = argc == 2 ? DB::parse<UInt64>(argv[1]) : 10ULL;
|
||||
|
||||
DB::ParserSelectQuery parser;
|
||||
DB::ASTPtr ast;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
|
||||
@ -30,7 +29,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
size_t n = argc == 2 ? Poco::NumberParser::parseUnsigned64(argv[1]) : 10ULL;
|
||||
size_t n = argc == 2 ? DB::parse<UInt64>(argv[1]) : 10ULL;
|
||||
|
||||
DB::ParserSelectQuery parser;
|
||||
DB::ASTPtr ast;
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromFileDescriptor.h>
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromFileDescriptor.h>
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <Yandex/Common.h>
|
||||
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
@ -1142,7 +1140,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
/* std::string s(' ', 20);
|
||||
DB::WriteBufferFromString wb(s);
|
||||
DB::Faster::writeIntText(Poco::NumberParser::parseUnsigned64(std::string(argv[1])), wb);
|
||||
DB::Faster::writeIntText(DB::parse<UInt64>(argv[1]), wb);
|
||||
std::cerr << s << std::endl;*/
|
||||
|
||||
try
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <DB/IO/VarInt.h>
|
||||
#include <DB/IO/WriteBufferFromString.h>
|
||||
#include <DB/IO/ReadBufferFromString.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
#include <Poco/HexBinaryEncoder.h>
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ int main(int argc, char ** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
DB::UInt64 x = Poco::NumberParser::parseUnsigned64(argv[1]);
|
||||
DB::UInt64 x = DB::parse<UInt64>(argv[1]);
|
||||
Poco::HexBinaryEncoder hex(std::cout);
|
||||
DB::writeVarUInt(x, hex);
|
||||
std::cout << std::endl;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/ReadBuffer.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
@ -168,7 +166,7 @@ bool Limits::trySet(const String & name, const String & value)
|
||||
|| name == "max_rows_in_distinct"
|
||||
|| name == "max_bytes_in_distinct")
|
||||
{
|
||||
if (!trySet(name, Poco::NumberParser::parseUnsigned64(value)))
|
||||
if (!trySet(name, parse<UInt64>(value)))
|
||||
throw Exception("Logical error: unknown setting " + name, ErrorCodes::UNKNOWN_SETTING);
|
||||
}
|
||||
else if (name == "read_overflow_mode"
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <DB/IO/ReadBuffer.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
@ -84,7 +82,7 @@ void Settings::set(const String & name, const String & value)
|
||||
|| name == "connections_with_failover_max_tries"
|
||||
|| name == "sign_rewrite")
|
||||
{
|
||||
set(name, Poco::NumberParser::parseUnsigned64(value));
|
||||
set(name, parse<UInt64>(value));
|
||||
}
|
||||
else if (name == "profile")
|
||||
{
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <Poco/ConsoleChannel.h>
|
||||
|
||||
#include <DB/IO/ReadBufferFromIStream.h>
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <iomanip>
|
||||
|
||||
#include <Poco/URI.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
|
||||
#include <statdaemons/Stopwatch.h>
|
||||
|
||||
@ -57,7 +56,7 @@ void HTTPHandler::processQuery(Poco::Net::NameValueCollection & params, Poco::Ne
|
||||
SharedPtr<ReadBuffer> in_post_maybe_compressed;
|
||||
|
||||
/// Если указано decompress, то будем разжимать то, что передано POST-ом.
|
||||
if (0 != Poco::NumberParser::parseUnsigned(params.get("decompress", "0")))
|
||||
if (parse<bool>(params.get("decompress", "0")))
|
||||
in_post_maybe_compressed = new CompressedReadBuffer(*in_post);
|
||||
else
|
||||
in_post_maybe_compressed = in_post;
|
||||
@ -68,7 +67,7 @@ void HTTPHandler::processQuery(Poco::Net::NameValueCollection & params, Poco::Ne
|
||||
SharedPtr<WriteBuffer> out = new WriteBufferFromHTTPServerResponse(response);
|
||||
SharedPtr<WriteBuffer> out_maybe_compressed;
|
||||
|
||||
if (0 != Poco::NumberParser::parseUnsigned(params.get("compress", "0")))
|
||||
if (parse<bool>(params.get("compress", "0")))
|
||||
out_maybe_compressed = new CompressedWriteBuffer(*out);
|
||||
else
|
||||
out_maybe_compressed = out;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include <Yandex/DateLUT.h>
|
||||
#include <Yandex/time2str.h>
|
||||
#include <Poco/DateTimeParser.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <Poco/AutoPtr.h>
|
||||
|
||||
#include "OLAPQueryParser.h"
|
||||
#include <DB/Core/ErrorCodes.h>
|
||||
#include <DB/Core/Exception.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -36,7 +36,7 @@ QueryParser::AttributeWithParameter QueryParser::parseAttributeWithParameter(con
|
||||
if (matches.size() == 3)
|
||||
{
|
||||
res.first = s.substr(matches[1].offset, matches[1].length);
|
||||
res.second = Poco::NumberParser::parseUnsigned(s.substr(matches[2].offset, matches[2].length));
|
||||
res.second = DB::parse<unsigned>(s.substr(matches[2].offset, matches[2].length));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,7 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
||||
|
||||
result.CounterID = 0;
|
||||
if (result.query->getElementsByTagName(CounterID_element_name)->length() > 0)
|
||||
result.CounterID = Poco::NumberParser::parseUnsigned(getValueOfOneTextElement(result.query, CounterID_element_name));
|
||||
result.CounterID = DB::parse<unsigned>(getValueOfOneTextElement(result.query, CounterID_element_name));
|
||||
|
||||
int time_zone_diff = 0;
|
||||
result.date_first = Yandex::Time2Date(Poco::DateTimeParser::parse(
|
||||
@ -116,13 +116,13 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
||||
{
|
||||
/// выставить дополнительное локальное ограничение на максимальный размер результата
|
||||
|
||||
result.max_result_size = Poco::NumberParser::parseUnsigned(settings_child_nodes->item(i)->innerText());
|
||||
result.max_result_size = DB::parse<unsigned>(settings_child_nodes->item(i)->innerText());
|
||||
}
|
||||
else if (settings_child_nodes->item(i)->nodeName() == "max_execution_time")
|
||||
{
|
||||
/// выставить дополнительное локальное ограничение на максимальное время выполнения запроса
|
||||
|
||||
result.max_execution_time = Poco::NumberParser::parseUnsigned(settings_child_nodes->item(i)->innerText());
|
||||
result.max_execution_time = DB::parse<unsigned>(settings_child_nodes->item(i)->innerText());
|
||||
}
|
||||
else if (settings_child_nodes->item(i)->nodeName() == "cut_date_last")
|
||||
{
|
||||
@ -158,14 +158,14 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
||||
{
|
||||
/// выставить количество потоков для обработки запроса
|
||||
|
||||
result.concurrency = Poco::NumberParser::parseUnsigned(settings_child_nodes->item(i)->innerText());
|
||||
result.concurrency = DB::parse<unsigned>(settings_child_nodes->item(i)->innerText());
|
||||
}
|
||||
else if (settings_child_nodes->item(i)->nodeName() == "max_threads_per_counter")
|
||||
{
|
||||
/** Выставить локальное ограничение на максимальное количество обрабатываемых запросов
|
||||
* Оно может быть больше, чем ограничение по-умолчанию.
|
||||
*/
|
||||
result.max_threads_per_counter = Poco::NumberParser::parseUnsigned(settings_child_nodes->item(i)->innerText());
|
||||
result.max_threads_per_counter = DB::parse<unsigned>(settings_child_nodes->item(i)->innerText());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
||||
if (limit_nodes->length() > 1)
|
||||
throw Exception(std::string("Found more than one node limit"), ErrorCodes::FOUND_MORE_THAN_ONE_NODE);
|
||||
if (limit_nodes->length() == 1)
|
||||
result.limit = Poco::NumberParser::parseUnsigned(limit_nodes->item(0)->innerText());
|
||||
result.limit = DB::parse<unsigned>(limit_nodes->item(0)->innerText());
|
||||
|
||||
LOG_DEBUG(log, "CounterID: " << result.CounterID
|
||||
<< ", dates: " << Yandex::Date2Str(result.date_first) << " - " << Yandex::Date2Str(result.date_last));
|
||||
@ -320,7 +320,7 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
||||
{
|
||||
if (index_direction_nodes->item(j)->nodeName() == "index")
|
||||
{
|
||||
column.index = Poco::NumberParser::parseUnsigned(index_direction_nodes->item(j)->innerText());
|
||||
column.index = DB::parse<unsigned>(index_direction_nodes->item(j)->innerText());
|
||||
if (column.index < 1 || column.index > result.key_attributes.size() + result.aggregates.size())
|
||||
throw Exception("Index of column in sort clause is out of range.",
|
||||
ErrorCodes::INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE);
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <numeric>
|
||||
|
||||
#include <Poco/DirectoryIterator.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <Poco/Ext/ScopedTry.h>
|
||||
|
||||
#include <Yandex/time2str.h>
|
||||
@ -502,9 +501,9 @@ void StorageMergeTree::loadDataParts()
|
||||
DataPartPtr part = new DataPart(*this);
|
||||
part->left_date = date_lut.toDayNum(Yandex::OrderedIdentifier2Date(file_name.substr(matches[1].offset, matches[1].length)));
|
||||
part->right_date = date_lut.toDayNum(Yandex::OrderedIdentifier2Date(file_name.substr(matches[2].offset, matches[2].length)));
|
||||
part->left = Poco::NumberParser::parseUnsigned64(file_name.substr(matches[3].offset, matches[3].length));
|
||||
part->right = Poco::NumberParser::parseUnsigned64(file_name.substr(matches[4].offset, matches[4].length));
|
||||
part->level = Poco::NumberParser::parseUnsigned(file_name.substr(matches[5].offset, matches[5].length));
|
||||
part->left = parse<UInt64>(file_name.substr(matches[3].offset, matches[3].length));
|
||||
part->right = parse<UInt64>(file_name.substr(matches[4].offset, matches[4].length));
|
||||
part->level = parse<UInt32>(file_name.substr(matches[5].offset, matches[5].length));
|
||||
part->name = file_name;
|
||||
|
||||
/// Размер - в количестве засечек.
|
||||
|
Loading…
Reference in New Issue
Block a user