Less dependencies [#CLICKHOUSE-2].

This commit is contained in:
Alexey Milovidov 2017-04-16 08:40:17 +03:00
parent 189b58b6c6
commit 41e97787e3
35 changed files with 120 additions and 119 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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_))

View File

@ -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

View File

@ -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>

View File

@ -1,7 +1,7 @@
#pragma once
#include <atomic>
#include <common/Common.h>
#include <common/Types.h>
#include <Common/CurrentMetrics.h>

View File

@ -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>

View File

@ -1,7 +1,7 @@
#pragma once
#include <atomic>
#include <common/Common.h>
#include <common/Types.h>
#include <Core/Defines.h>

View File

@ -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));
}
}

View File

@ -2,7 +2,7 @@
#include <vector>
#include <boost/noncopyable.hpp>
#include <common/Common.h>
#include <common/Types.h>
#include <common/singleton.h>

View File

@ -3,7 +3,7 @@
#include <string>
#include <vector>
#include <Poco/Exception.h>
#include <common/Common.h>
#include <common/Types.h>
#include <Core/StringRef.h>

View File

@ -1,7 +1,7 @@
#pragma once
#include <common/singleton.h>
#include <common/Common.h>
#include <common/Types.h>
/** @brief Класс, позволяющий узнавать, принадлежит ли поисковая система или операционная система

View File

@ -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));
}
}

View File

@ -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()) {}
};

View File

@ -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.";
else
message << " before: " << mysqlxx::escape << String(buf.position(), std::min(SHOW_CHARS_ON_SYNTAX_ERROR, buf.buffer().end() - buf.position()));
if (buf.eof())
out << " at end of stream.";
else
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 << ". ";
if (!additional_message.empty())
out << additional_message << ". ";
if (name != "DB::Exception")
message_stream << name << ". ";
if (name != "DB::Exception")
out << name << ". ";
message_stream << message
<< ". Stack trace:\n\n" << stack_trace;
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)

View File

@ -7,9 +7,7 @@
#include <type_traits>
#include <common/Common.h>
#include <common/DateLUT.h>
#include <common/LocalDate.h>
#include <common/LocalDateTime.h>

View File

@ -5,7 +5,6 @@
#include <limits>
#include <algorithm>
#include <common/Common.h>
#include <common/DateLUT.h>
#include <common/LocalDate.h>
#include <common/LocalDateTime.h>

View File

@ -1,7 +1,7 @@
#include <iostream>
#include <iomanip>
#include <common/Common.h>
#include <common/Types.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>

View File

@ -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();
}

View File

@ -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>

View File

@ -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)

View File

@ -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)
{

View File

@ -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, '\'');
}
}
};

View File

@ -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;
}
};

View File

@ -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

View File

@ -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>

View File

@ -3,7 +3,7 @@
#include <typeinfo>
#include <Poco/Exception.h>
#include <Core/StringRef.h>
#include <common/Common.h>
#include <common/Types.h>
/** Очень простой класс для чтения JSON (или его кусочков).

View File

@ -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.

View 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

View File

@ -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>

View File

@ -41,10 +41,10 @@ struct EscapeManipResult
EscapeManipResult(std::ostream & ostr_) : ostr(ostr_) {}
std::ostream & operator<< (bool value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (bool value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (unsigned char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (signed char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (signed char value) { return ostr << static_cast<int>(value); }
template <typename T>
typename std::enable_if<std::is_arithmetic<T>::value, std::ostream &>::type
@ -163,10 +163,10 @@ public:
QuoteManipResult(std::ostream & ostr_) : ostr(ostr_) {}
std::ostream & operator<< (bool value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (bool value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (unsigned char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (signed char value) { return ostr << static_cast<int>(value); }
std::ostream & operator<< (signed char value) { return ostr << static_cast<int>(value); }
template <typename T>
typename std::enable_if<std::is_arithmetic<T>::value, std::ostream &>::type
@ -318,8 +318,8 @@ struct UnEscapeManipResult
std::istream & operator>> (bool & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (unsigned char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (signed char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (unsigned char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (signed char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
template <typename T>
typename std::enable_if<std::is_arithmetic<T>::value, std::istream &>::type
@ -418,8 +418,8 @@ public:
std::istream & operator>> (bool & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (unsigned char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (signed char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (unsigned char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
std::istream & operator>> (signed char & value) { int tmp = 0; istr >> tmp; value = tmp; return istr; }
template <typename T>
typename std::enable_if<std::is_arithmetic<T>::value, std::istream &>::type

View File

@ -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>
@ -239,27 +239,25 @@ private:
};
template <> inline bool Value::get<bool >() const { return getBool(); }
template <> inline char Value::get<char >() const { return getInt(); }
template <> inline signed char Value::get<signed char >() const { return getInt(); }
template <> inline bool Value::get<bool >() const { return getBool(); }
template <> inline char Value::get<char >() const { return getInt(); }
template <> inline signed char Value::get<signed char >() const { return getInt(); }
template <> inline unsigned char Value::get<unsigned char >() const { return getUInt(); }
template <> inline short Value::get<short >() const { return getInt(); }
template <> inline unsigned short Value::get<unsigned short >() const { return getUInt(); }
template <> inline int Value::get<int >() const { return getInt(); }
template <> inline unsigned int Value::get<unsigned int >() const { return getUInt(); }
template <> inline long Value::get<long >() const { return getInt(); }
template <> inline unsigned long Value::get<unsigned long >() const { return getUInt(); }
template <> inline long long Value::get<long long >() const { return getInt(); }
template <> inline unsigned long long Value::get<unsigned long long >() const { return getUInt(); }
template <> inline float Value::get<float >() const { return getDouble(); }
template <> inline double Value::get<double >() const { return getDouble(); }
template <> inline std::string Value::get<std::string >() const { return getString(); }
template <> inline short Value::get<short >() const { return getInt(); }
template <> inline unsigned short Value::get<unsigned short >() const { return getUInt(); }
template <> inline int Value::get<int >() const { return getInt(); }
template <> inline unsigned int Value::get<unsigned int >() const { return getUInt(); }
template <> inline long Value::get<long >() const { return getInt(); }
template <> inline unsigned long Value::get<unsigned long >() const { return getUInt(); }
template <> inline long long Value::get<long long >() const { return getInt(); }
template <> inline unsigned long long Value::get<unsigned long long >() const { return getUInt(); }
template <> inline float Value::get<float >() const { return getDouble(); }
template <> inline double Value::get<double >() const { return getDouble(); }
template <> inline std::string Value::get<std::string >() const { return getString(); }
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); }
template <typename T> inline T Value::get() const { return T(*this); }
inline std::ostream & operator<< (std::ostream & ostr, const Value & x)

View File

@ -1,5 +1,5 @@
#pragma once
#include <common/Common.h>
#include <common/Types.h>
#include <future>
#include <memory>
#include <vector>

View File

@ -5,7 +5,7 @@
#include <emmintrin.h>
#endif
#include <common/Common.h>
#include <common/Types.h>
#include <Poco/NumberParser.h>
#include <IO/ReadBufferFromFileDescriptor.h>