2021-06-14 04:13:35 +00:00
|
|
|
#include <Common/FieldVisitorDump.h>
|
|
|
|
|
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
#include <IO/Operators.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static inline String formatQuotedWithPrefix(T x, const char * prefix)
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
writeCString(prefix, wb);
|
|
|
|
writeQuoted(x, wb);
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static inline void writeQuoted(const DecimalField<T> & x, WriteBuffer & buf)
|
|
|
|
{
|
|
|
|
writeChar('\'', buf);
|
2021-08-16 08:03:23 +00:00
|
|
|
writeText(x.getValue(), x.getScale(), buf, {});
|
2021-06-14 04:13:35 +00:00
|
|
|
writeChar('\'', buf);
|
|
|
|
}
|
|
|
|
|
2021-08-29 19:00:00 +00:00
|
|
|
String FieldVisitorDump::operator() (const Null & x) const { return x.isNegativeInfinity() ? "-Inf" : (x.isPositiveInfinity() ? "+Inf" : "NULL"); }
|
2021-06-14 04:13:35 +00:00
|
|
|
String FieldVisitorDump::operator() (const UInt64 & x) const { return formatQuotedWithPrefix(x, "UInt64_"); }
|
|
|
|
String FieldVisitorDump::operator() (const Int64 & x) const { return formatQuotedWithPrefix(x, "Int64_"); }
|
|
|
|
String FieldVisitorDump::operator() (const Float64 & x) const { return formatQuotedWithPrefix(x, "Float64_"); }
|
|
|
|
String FieldVisitorDump::operator() (const DecimalField<Decimal32> & x) const { return formatQuotedWithPrefix(x, "Decimal32_"); }
|
|
|
|
String FieldVisitorDump::operator() (const DecimalField<Decimal64> & x) const { return formatQuotedWithPrefix(x, "Decimal64_"); }
|
|
|
|
String FieldVisitorDump::operator() (const DecimalField<Decimal128> & x) const { return formatQuotedWithPrefix(x, "Decimal128_"); }
|
|
|
|
String FieldVisitorDump::operator() (const DecimalField<Decimal256> & x) const { return formatQuotedWithPrefix(x, "Decimal256_"); }
|
|
|
|
String FieldVisitorDump::operator() (const UInt128 & x) const { return formatQuotedWithPrefix(x, "UInt128_"); }
|
|
|
|
String FieldVisitorDump::operator() (const UInt256 & x) const { return formatQuotedWithPrefix(x, "UInt256_"); }
|
|
|
|
String FieldVisitorDump::operator() (const Int128 & x) const { return formatQuotedWithPrefix(x, "Int128_"); }
|
|
|
|
String FieldVisitorDump::operator() (const Int256 & x) const { return formatQuotedWithPrefix(x, "Int256_"); }
|
|
|
|
String FieldVisitorDump::operator() (const UUID & x) const { return formatQuotedWithPrefix(x, "UUID_"); }
|
2022-01-18 11:52:27 +00:00
|
|
|
String FieldVisitorDump::operator() (const bool & x) const { return formatQuotedWithPrefix(x, "Bool_"); }
|
2021-06-14 04:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
String FieldVisitorDump::operator() (const String & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
writeQuoted(x, wb);
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
String FieldVisitorDump::operator() (const Array & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
|
|
|
|
wb << "Array_[";
|
|
|
|
for (auto it = x.begin(); it != x.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != x.begin())
|
|
|
|
wb << ", ";
|
|
|
|
wb << applyVisitor(*this, *it);
|
|
|
|
}
|
|
|
|
wb << ']';
|
|
|
|
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
String FieldVisitorDump::operator() (const Tuple & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
|
|
|
|
wb << "Tuple_(";
|
|
|
|
for (auto it = x.begin(); it != x.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != x.begin())
|
|
|
|
wb << ", ";
|
|
|
|
wb << applyVisitor(*this, *it);
|
|
|
|
}
|
|
|
|
wb << ')';
|
|
|
|
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
String FieldVisitorDump::operator() (const Map & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
|
|
|
|
wb << "Map_(";
|
|
|
|
for (auto it = x.begin(); it != x.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != x.begin())
|
|
|
|
wb << ", ";
|
|
|
|
wb << applyVisitor(*this, *it);
|
|
|
|
}
|
|
|
|
wb << ')';
|
|
|
|
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
2021-08-20 21:11:22 +00:00
|
|
|
String FieldVisitorDump::operator() (const Object & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
|
|
|
|
wb << "Object_(";
|
|
|
|
for (auto it = x.begin(); it != x.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != x.begin())
|
|
|
|
wb << ", ";
|
|
|
|
wb << "(" << it->first << ", " << applyVisitor(*this, it->second) << ")";
|
|
|
|
}
|
|
|
|
wb << ')';
|
|
|
|
|
|
|
|
return wb.str();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-06-14 04:13:35 +00:00
|
|
|
String FieldVisitorDump::operator() (const AggregateFunctionStateData & x) const
|
|
|
|
{
|
|
|
|
WriteBufferFromOwnString wb;
|
|
|
|
wb << "AggregateFunctionState_(";
|
|
|
|
writeQuoted(x.name, wb);
|
|
|
|
wb << ", ";
|
|
|
|
writeQuoted(x.data, wb);
|
|
|
|
wb << ')';
|
|
|
|
return wb.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|