2021-06-14 04:13:35 +00:00
|
|
|
#include <Common/FieldVisitorWriteBinary.h>
|
|
|
|
|
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-08-27 14:09:15 +00:00
|
|
|
void FieldVisitorWriteBinary::operator() (const Null &, WriteBuffer &) const {}
|
2021-06-14 04:13:35 +00:00
|
|
|
void FieldVisitorWriteBinary::operator() (const UInt64 & x, WriteBuffer & buf) const { writeVarUInt(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Int64 & x, WriteBuffer & buf) const { writeVarInt(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Float64 & x, WriteBuffer & buf) const { writeFloatBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const String & x, WriteBuffer & buf) const { writeStringBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const UInt128 & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Int128 & x, WriteBuffer & buf) const { writeVarInt(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const UInt256 & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Int256 & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const UUID & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
2022-11-14 14:17:17 +00:00
|
|
|
void FieldVisitorWriteBinary::operator() (const IPv4 & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const IPv6 & x, WriteBuffer & buf) const { writeBinary(x, buf); }
|
2021-06-14 04:13:35 +00:00
|
|
|
void FieldVisitorWriteBinary::operator() (const DecimalField<Decimal32> & x, WriteBuffer & buf) const { writeBinary(x.getValue(), buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const DecimalField<Decimal64> & x, WriteBuffer & buf) const { writeBinary(x.getValue(), buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const DecimalField<Decimal128> & x, WriteBuffer & buf) const { writeBinary(x.getValue(), buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const DecimalField<Decimal256> & x, WriteBuffer & buf) const { writeBinary(x.getValue(), buf); }
|
|
|
|
void FieldVisitorWriteBinary::operator() (const AggregateFunctionStateData & x, WriteBuffer & buf) const
|
|
|
|
{
|
|
|
|
writeStringBinary(x.name, buf);
|
|
|
|
writeStringBinary(x.data, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Array & x, WriteBuffer & buf) const
|
|
|
|
{
|
|
|
|
const size_t size = x.size();
|
|
|
|
writeBinary(size, buf);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < size; ++i)
|
|
|
|
{
|
|
|
|
const UInt8 type = x[i].getType();
|
|
|
|
writeBinary(type, buf);
|
|
|
|
Field::dispatch([&buf] (const auto & value) { FieldVisitorWriteBinary()(value, buf); }, x[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Tuple & x, WriteBuffer & buf) const
|
|
|
|
{
|
|
|
|
const size_t size = x.size();
|
|
|
|
writeBinary(size, buf);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < size; ++i)
|
|
|
|
{
|
|
|
|
const UInt8 type = x[i].getType();
|
|
|
|
writeBinary(type, buf);
|
|
|
|
Field::dispatch([&buf] (const auto & value) { FieldVisitorWriteBinary()(value, buf); }, x[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FieldVisitorWriteBinary::operator() (const Map & x, WriteBuffer & buf) const
|
|
|
|
{
|
|
|
|
const size_t size = x.size();
|
|
|
|
writeBinary(size, buf);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < size; ++i)
|
|
|
|
{
|
|
|
|
const UInt8 type = x[i].getType();
|
|
|
|
writeBinary(type, buf);
|
|
|
|
Field::dispatch([&buf] (const auto & value) { FieldVisitorWriteBinary()(value, buf); }, x[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-20 21:11:22 +00:00
|
|
|
void FieldVisitorWriteBinary::operator() (const Object & x, WriteBuffer & buf) const
|
|
|
|
{
|
|
|
|
const size_t size = x.size();
|
|
|
|
writeBinary(size, buf);
|
|
|
|
|
|
|
|
for (const auto & [key, value] : x)
|
|
|
|
{
|
|
|
|
const UInt8 type = value.getType();
|
|
|
|
writeBinary(type, buf);
|
|
|
|
writeBinary(key, buf);
|
|
|
|
Field::dispatch([&buf] (const auto & val) { FieldVisitorWriteBinary()(val, buf); }, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 11:52:27 +00:00
|
|
|
void FieldVisitorWriteBinary::operator()(const bool & x, WriteBuffer & buf) const
|
|
|
|
{
|
2022-04-18 08:18:31 +00:00
|
|
|
writeBinary(static_cast<UInt8>(x), buf);
|
2022-01-18 11:52:27 +00:00
|
|
|
}
|
|
|
|
|
2021-06-14 04:13:35 +00:00
|
|
|
}
|
|
|
|
|