mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Less dependencies [#CLICKHOUSE-2].
This commit is contained in:
parent
189b58b6c6
commit
41e97787e3
@ -4,7 +4,7 @@
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <sstream>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <IO/ReadBuffer.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <climits>
|
||||
#include <sstream>
|
||||
#include <AggregateFunctions/ReservoirSampler.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <Common/HashTable/Hash.h>
|
||||
#include <IO/ReadBuffer.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
#include <IO/WriteBuffer.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
@ -14,7 +14,7 @@
|
||||
#include <Common/HashTable/Hash.h>
|
||||
|
||||
|
||||
/** Approximate calculation of anything, as a rule, is constructed according to the following scheme:
|
||||
/** Approximate calculation of anything, as usual, is constructed according to the following scheme:
|
||||
* - some data structure is used to calculate the value of X;
|
||||
* - Not all values are added to the data structure, but only selected ones (according to some selectivity criteria);
|
||||
* - after processing all elements, the data structure is in some state S;
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <Common/Exception.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <common/Common.h>
|
||||
#include <Poco/String.h>
|
||||
|
||||
Collator::Collator(const std::string & locale_) : locale(Poco::toLower(locale_))
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
#define SMALL_READ_WRITE_BUFFER_SIZE 16
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <Common/HyperLogLogBiasEstimator.h>
|
||||
#include <Common/CompactArray.h>
|
||||
#include <Common/HashTable/Hash.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <Common/CurrentMetrics.h>
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <time.h>
|
||||
#include <mutex>
|
||||
#include <Poco/ScopedLock.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <common/apple_rt.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
#include <Core/Defines.h>
|
||||
|
||||
|
@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Common.h> /// VisitID_t
|
||||
#include <common/MetrikaTypes.h>
|
||||
#include <common/LocalDate.h>
|
||||
#include <common/LocalDateTime.h>
|
||||
#include <Core/Field.h>
|
||||
#include <mysqlxx/Null.h>
|
||||
|
||||
|
||||
/// This is for Yandex.Metrica code.
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
|
||||
/// Перевести что угодно в Field.
|
||||
template <typename T>
|
||||
inline Field toField(const T & x)
|
||||
@ -33,11 +35,4 @@ inline Field toField(const VisitID_t & x)
|
||||
return toField(static_cast<UInt64>(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline Field toField(const mysqlxx::Null<T> & x)
|
||||
{
|
||||
return x.isNull() ? Field(Null()) : toField(static_cast<const T &>(x));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <common/singleton.h>
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <Poco/Exception.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <Core/StringRef.h>
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/singleton.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
|
||||
/** @brief Класс, позволяющий узнавать, принадлежит ли поисковая система или операционная система
|
||||
|
@ -53,6 +53,8 @@ namespace mysqlxx
|
||||
{
|
||||
throw Poco::Exception("Cannot unquote Tuple with mysqlxx::unquote.");
|
||||
}
|
||||
|
||||
template <> inline VisitID_t Value::get<VisitID_t>() const { return VisitID_t(getUInt()); }
|
||||
}
|
||||
|
||||
|
||||
@ -97,5 +99,12 @@ inline void writeQuoted(const mysqlxx::Null<T> & x, WriteBuffer & buf)
|
||||
writeText(static_cast<const T &>(x), buf);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline Field toField(const mysqlxx::Null<T> & x)
|
||||
{
|
||||
return x.isNull() ? Field(Null()) : toField(static_cast<const T &>(x));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace DB
|
||||
class ReadBufferFromString : public ReadBufferFromMemory
|
||||
{
|
||||
public:
|
||||
/// std::string or mysqlxx::Value
|
||||
/// std::string or something similar
|
||||
template <typename S>
|
||||
ReadBufferFromString(const S & s) : ReadBufferFromMemory(s.data(), s.size()) {}
|
||||
};
|
||||
|
@ -1,13 +1,12 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <mysqlxx/Manip.h>
|
||||
|
||||
#include <Core/Defines.h>
|
||||
#include <Common/PODArray.h>
|
||||
#include <Common/StringUtils.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
#include <IO/Operators.h>
|
||||
#include <common/find_first_symbols.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
@ -22,15 +21,18 @@ namespace ErrorCodes
|
||||
|
||||
static void __attribute__((__noinline__)) throwAtAssertionFailed(const char * s, ReadBuffer & buf)
|
||||
{
|
||||
std::stringstream message;
|
||||
message << "Cannot parse input: expected " << mysqlxx::escape << s;
|
||||
std::string message;
|
||||
{
|
||||
WriteBufferFromString out(message);
|
||||
out << "Cannot parse input: expected " << escape << s;
|
||||
|
||||
if (buf.eof())
|
||||
message << " at end of stream.";
|
||||
out << " at end of stream.";
|
||||
else
|
||||
message << " before: " << mysqlxx::escape << String(buf.position(), std::min(SHOW_CHARS_ON_SYNTAX_ERROR, buf.buffer().end() - buf.position()));
|
||||
out << " before: " << escape << String(buf.position(), std::min(SHOW_CHARS_ON_SYNTAX_ERROR, buf.buffer().end() - buf.position()));
|
||||
}
|
||||
|
||||
throw Exception(message.str(), ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED);
|
||||
throw Exception(message, ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED);
|
||||
}
|
||||
|
||||
|
||||
@ -685,25 +687,28 @@ void readException(Exception & e, ReadBuffer & buf, const String & additional_me
|
||||
readBinary(stack_trace, buf);
|
||||
readBinary(has_nested, buf);
|
||||
|
||||
std::stringstream message_stream;
|
||||
std::string new_message;
|
||||
{
|
||||
WriteBufferFromString out(new_message);
|
||||
|
||||
if (!additional_message.empty())
|
||||
message_stream << additional_message << ". ";
|
||||
out << additional_message << ". ";
|
||||
|
||||
if (name != "DB::Exception")
|
||||
message_stream << name << ". ";
|
||||
out << name << ". ";
|
||||
|
||||
message_stream << message
|
||||
out << message
|
||||
<< ". Stack trace:\n\n" << stack_trace;
|
||||
}
|
||||
|
||||
if (has_nested)
|
||||
{
|
||||
Exception nested;
|
||||
readException(nested, buf);
|
||||
e = Exception(message_stream.str(), nested, code);
|
||||
e = Exception(new_message, nested, code);
|
||||
}
|
||||
else
|
||||
e = Exception(message_stream.str(), code);
|
||||
e = Exception(new_message, code);
|
||||
}
|
||||
|
||||
void readAndThrowException(ReadBuffer & buf, const String & additional_message)
|
||||
|
@ -7,9 +7,7 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/DateLUT.h>
|
||||
|
||||
#include <common/LocalDate.h>
|
||||
#include <common/LocalDateTime.h>
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/DateLUT.h>
|
||||
#include <common/LocalDate.h>
|
||||
#include <common/LocalDateTime.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <Interpreters/executeQuery.h>
|
||||
#include <Interpreters/InterpreterShowTablesQuery.h>
|
||||
|
||||
#include <mysqlxx/Manip.h>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -36,10 +36,10 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
|
||||
context.assertDatabaseExists(database, false);
|
||||
|
||||
std::stringstream rewritten_query;
|
||||
rewritten_query << "SELECT name FROM system.tables WHERE database = " << mysqlxx::quote << database;
|
||||
rewritten_query << "SELECT name FROM system.tables WHERE database = " << std::quoted(database, '\'');
|
||||
|
||||
if (!query.like.empty())
|
||||
rewritten_query << " AND name " << (query.not_like ? "NOT " : "") << "LIKE " << mysqlxx::quote << query.like;
|
||||
rewritten_query << " AND name " << (query.not_like ? "NOT " : "") << "LIKE " << std::quoted(query.like, '\'');
|
||||
|
||||
return rewritten_query.str();
|
||||
}
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
#include <Poco/Net/IPAddress.h>
|
||||
|
||||
#include <common/Common.h>
|
||||
|
||||
#include <Core/Types.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <Parsers/ASTAlterQuery.h>
|
||||
#include <mysqlxx/Manip.h>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -137,7 +138,7 @@ void ASTAlterQuery::formatImpl(const FormatSettings & settings, FormatState & st
|
||||
<< "PARTITION " << (settings.hilite ? hilite_none : "");
|
||||
p.partition->formatImpl(settings, state, frame);
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
||||
<< " FROM " << (settings.hilite ? hilite_none : "") << mysqlxx::quote << p.from;
|
||||
<< " FROM " << (settings.hilite ? hilite_none : "") << std::quoted(p.from, '\'');
|
||||
}
|
||||
else if (p.type == ASTAlterQuery::FREEZE_PARTITION)
|
||||
{
|
||||
@ -147,7 +148,7 @@ void ASTAlterQuery::formatImpl(const FormatSettings & settings, FormatState & st
|
||||
if (!p.with_name.empty())
|
||||
{
|
||||
settings.ostr << " " << (settings.hilite ? hilite_keyword : "") << "WITH NAME" << (settings.hilite ? hilite_none : "")
|
||||
<< " " << mysqlxx::quote << p.with_name;
|
||||
<< " " << std::quoted(p.with_name, '\'');
|
||||
}
|
||||
}
|
||||
else if (p.type == ASTAlterQuery::RESHARD_PARTITION)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <mysqlxx/Manip.h>
|
||||
#include <iomanip>
|
||||
#include <Parsers/ASTInsertQuery.h>
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ void ASTInsertQuery::formatImpl(const FormatSettings & settings, FormatState & s
|
||||
|
||||
if (!insert_id.empty())
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " ID = " << (settings.hilite ? hilite_none : "")
|
||||
<< mysqlxx::quote << insert_id;
|
||||
<< std::quoted(insert_id, '\'');
|
||||
|
||||
if (columns)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mysqlxx/Manip.h>
|
||||
#include <iomanip>
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Parsers/ASTQueryWithOutput.h>
|
||||
|
||||
@ -50,7 +50,7 @@ protected:
|
||||
|
||||
if (!like.empty())
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIKE " << (settings.hilite ? hilite_none : "")
|
||||
<< mysqlxx::quote << like;
|
||||
<< std::quoted(like, '\'');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Core/Types.h>
|
||||
#include <mysqlxx/Manip.h>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -24,7 +24,7 @@ protected:
|
||||
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
||||
{
|
||||
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
||||
settings.ostr << settings.nl_or_ws << indent_str << mysqlxx::quote << path << " WEIGHT " << weight;
|
||||
settings.ostr << settings.nl_or_ws << indent_str << std::quoted(path, '\'') << " WEIGHT " << weight;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,8 @@ add_library (common
|
||||
src/JSON.cpp
|
||||
|
||||
include/common/ApplicationServerExt.h
|
||||
include/common/Common.h
|
||||
include/common/Types.h
|
||||
include/common/MetrikaTypes.h
|
||||
include/common/DateLUT.h
|
||||
include/common/DateLUTImpl.h
|
||||
include/common/LocalDate.h
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <common/singleton.h>
|
||||
#include <common/likely.h>
|
||||
#include <common/strong_typedef.h>
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <typeinfo>
|
||||
#include <Poco/Exception.h>
|
||||
#include <Core/StringRef.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
|
||||
|
||||
/** Очень простой класс для чтения JSON (или его кусочков).
|
||||
|
@ -1,31 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
#include <Poco/Types.h>
|
||||
|
||||
#include <common/Types.h>
|
||||
#include <common/strong_typedef.h>
|
||||
|
||||
|
||||
using Int8 = Poco::Int8;
|
||||
using Int16 = Poco::Int16;
|
||||
using Int32 = Poco::Int32;
|
||||
using Int64 = Poco::Int64;
|
||||
|
||||
using UInt8 = Poco::UInt8;
|
||||
using UInt16 = Poco::UInt16;
|
||||
using UInt32 = Poco::UInt32;
|
||||
using UInt64 = Poco::UInt64;
|
||||
|
||||
|
||||
/// Обход проблемы с тем, что KDevelop не видит time_t и size_t (для подсветки синтаксиса).
|
||||
#ifdef IN_KDEVELOP_PARSER
|
||||
using time_t = Int64;
|
||||
using size_t = UInt64;
|
||||
#endif
|
||||
|
||||
|
||||
/// The following is for Yandex.Metrika code. Not used by ClickHouse.
|
||||
|
||||
|
20
libs/libcommon/include/common/Types.h
Normal file
20
libs/libcommon/include/common/Types.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <Poco/Types.h>
|
||||
|
||||
using Int8 = Poco::Int8;
|
||||
using Int16 = Poco::Int16;
|
||||
using Int32 = Poco::Int32;
|
||||
using Int64 = Poco::Int64;
|
||||
|
||||
using UInt8 = Poco::UInt8;
|
||||
using UInt16 = Poco::UInt16;
|
||||
using UInt32 = Poco::UInt32;
|
||||
using UInt64 = Poco::UInt64;
|
||||
|
||||
|
||||
/// Обход проблемы с тем, что KDevelop не видит time_t и size_t (для подсветки синтаксиса).
|
||||
#ifdef IN_KDEVELOP_PARSER
|
||||
using time_t = Int64;
|
||||
using size_t = UInt64;
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
#include <Poco/FileChannel.h>
|
||||
#include <Poco/SyslogChannel.h>
|
||||
#include <Poco/Version.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <common/logger_useful.h>
|
||||
#include <daemon/GraphiteWriter.h>
|
||||
#include <Common/ConfigProcessor.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <limits>
|
||||
|
||||
#include <common/exp10.h>
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <common/DateLUT.h>
|
||||
|
||||
#include <mysqlxx/Types.h>
|
||||
@ -257,8 +257,6 @@ template <> inline std::string Value::get<std::string >()
|
||||
template <> inline LocalDate Value::get<LocalDate >() const { return getDate(); }
|
||||
template <> inline LocalDateTime Value::get<LocalDateTime >() const { return getDateTime(); }
|
||||
|
||||
template <> inline VisitID_t Value::get<VisitID_t >() const { return VisitID_t(getUInt()); }
|
||||
|
||||
template <typename T> inline T Value::get() const { return T(*this); }
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
#include <common/Common.h>
|
||||
#include <common/Types.h>
|
||||
#include <Poco/NumberParser.h>
|
||||
#include <IO/ReadBufferFromFileDescriptor.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user