dbms: simpler [#METR-19266]

This commit is contained in:
Alexey Arno 2016-07-11 19:37:44 +03:00
parent 9c9b23b22e
commit 72576afb84
21 changed files with 265 additions and 523 deletions

View File

@ -54,6 +54,11 @@ public:
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
@ -66,10 +71,6 @@ public:
}
private:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};

View File

@ -62,6 +62,12 @@ public:
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
/** Записать размеры. */
void serializeOffsets(const IColumn & column, WriteBuffer & ostr, size_t offset = 0, size_t limit = 0) const;
@ -83,11 +89,6 @@ public:
private:
void serializeTextInternal(const IColumn & column, size_t row_num, WriteBuffer & ostr) const;
void deserializeTextQuotedInternal(IColumn & column, ReadBuffer & istr) const;
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};
}

View File

@ -54,60 +54,34 @@ private:
static_cast<ColumnType &>(column).getData().push_back(x); /// Важно делать это в конце - для exception safety.
}
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
{
writeChar('"', ostr);
writeDateText(DayNum_t(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
writeDateText(DayNum_t(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeChar('"', ostr);
}
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
DayNum_t x;
assertChar('"', istr);
readDateText(x, istr);
assertChar('"', istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
DayNum_t x;
assertChar('"', istr);
readDateText(x, istr);
assertChar('"', istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
{
writeChar('"', ostr);
writeDateText(DayNum_t(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
writeDateText(DayNum_t(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeChar('"', ostr);
}
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
LocalDate value;
readCSV(value, istr);
static_cast<ColumnType &>(column).getData().push_back(value.getDayNum());
}
LocalDate value;
readCSV(value, istr);
static_cast<ColumnType &>(column).getData().push_back(value.getDayNum());
}
};

View File

@ -54,64 +54,34 @@ private:
static_cast<ColumnType &>(column).getData().push_back(x); /// Важно делать это в конце - для exception safety.
}
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const override
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
{
writeChar('"', ostr);
serializeText(column, row_num, ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
serializeText(column, row_num, ostr);
writeChar('"', ostr);
}
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const override
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
time_t x;
assertChar('"', istr);
readDateTimeText(x, istr);
assertChar('"', istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
time_t x;
assertChar('"', istr);
readDateTimeText(x, istr);
assertChar('"', istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const override
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
{
writeChar('"', ostr);
serializeText(column, row_num, ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
serializeText(column, row_num, ostr);
writeChar('"', ostr);
}
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const override
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
LocalDateTime value;
readCSV(value, istr);
static_cast<ColumnType &>(column).getData().push_back(static_cast<time_t>(value));
}
LocalDateTime value;
readCSV(value, istr);
static_cast<ColumnType &>(column).getData().push_back(static_cast<time_t>(value));
}
};

View File

@ -85,6 +85,11 @@ public:
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
@ -94,13 +99,6 @@ public:
ColumnPtr createConstColumn(const size_t size, const Field & field) const override;
Field getDefault() const override;
private:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};

View File

@ -49,6 +49,11 @@ public:
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
@ -59,13 +64,6 @@ public:
{
return String();
}
private:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};
}

View File

@ -22,17 +22,15 @@ public:
void deserializeTextEscaped(IColumn & column, ReadBuffer & istr) const override;
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
ColumnPtr createColumn() const override;
ColumnPtr createConstColumn(size_t size, const Field & field) const override;
Field getDefault() const override;
size_t getSizeOfField() const override;
private:
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
};
}

View File

@ -24,6 +24,10 @@ public:
void deserializeTextEscaped(IColumn & column, ReadBuffer & istr) const override;
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
ColumnPtr createColumn() const override;
@ -33,12 +37,6 @@ public:
DataTypePtr & getNestedType();
const DataTypePtr & getNestedType() const;
private:
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
private:
DataTypePtr nested_data_type;
};

View File

@ -36,6 +36,11 @@ public:
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
@ -46,13 +51,6 @@ public:
{
return String("");
}
private:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};
}

View File

@ -39,6 +39,13 @@ public:
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override;
/// Кортежи в формате CSV будем сериализовать, как отдельные столбцы (то есть, теряя их вложенность в кортеж).
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override;
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
@ -50,12 +57,6 @@ public:
private:
void deserializeText(IColumn & column, ReadBuffer & istr) const;
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const override;
/// Кортежи в формате CSV будем сериализовать, как отдельные столбцы (то есть, теряя их вложенность в кортеж).
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const override;
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const override;
};
}

View File

@ -86,19 +86,11 @@ public:
/** Text serialization for the CSV format.
*/
inline void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map = nullptr) const
{
serializeTextCSVImpl(column, row_num, ostr, null_map);
}
virtual void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const = 0;
/** delimiter - the delimiter we expect when reading a value that is not double-quoted.
*/
inline void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter,
PaddedPODArray<UInt8> * null_map = nullptr) const
{
deserializeTextCSVImpl(column, istr, delimiter, null_map);
}
virtual void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const = 0;
/** Text serialization for displaying on a terminal or saving into a text file, and the like.
* Without escaping or quoting.
@ -107,17 +99,8 @@ public:
/** Text serialization as a literal for using with the JSON format.
*/
inline void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map = nullptr) const
{
serializeTextJSONImpl(column, row_num, ostr, null_map);
}
inline void deserializeTextJSON(IColumn & column, ReadBuffer & istr,
PaddedPODArray<UInt8> * null_map = nullptr) const
{
deserializeTextJSONImpl(column, istr, null_map);
}
virtual void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const = 0;
virtual void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const = 0;
/** Text serialization for putting into the XML format.
*/
@ -151,11 +134,6 @@ protected:
{
return (null_map != nullptr) && ((*null_map)[row_num] == 1);
}
virtual void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const = 0;
virtual void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, NullValuesByteMap * null_map) const = 0;
virtual void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const NullValuesByteMap * null_map) const = 0;
virtual void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map) const = 0;
};

View File

@ -40,6 +40,11 @@ public:
throwNoSerialization();
}
void deserializeBinary(IColumn & column, ReadBuffer & istr, size_t limit, double avg_value_size_hint) const override
{
throwNoSerialization();
}
void serializeTextEscaped(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
throwNoSerialization();
@ -60,7 +65,22 @@ public:
throwNoSerialization();
}
void deserializeBinary(IColumn & column, ReadBuffer & istr, size_t limit, double avg_value_size_hint) const override
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
throwNoSerialization();
}
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override
{
throwNoSerialization();
}
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
throwNoSerialization();
}
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override
{
throwNoSerialization();
}
@ -85,31 +105,6 @@ public:
throw Exception("Method getDefault() is not implemented for data type " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
protected:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const override
{
throwNoSerialization();
}
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const override
{
throwNoSerialization();
}
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const override
{
throwNoSerialization();
}
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const override
{
throwNoSerialization();
}
private:
void throwNoSerialization() const
{

View File

@ -66,11 +66,9 @@ protected:
deserializeText<NullSymbol::Quoted>(column, istr);
}
inline void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const override;
inline void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
PaddedPODArray<UInt8> * null_map) const override
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override
{
bool has_quote = false;
if (!istr.eof() && *istr.position() == '"') /// Понимаем число как в кавычках, так и без.
@ -88,9 +86,6 @@ protected:
assertString(NullSymbol::JSON::suffix, istr);
x = valueForJSONNull();
if (null_map != nullptr)
null_map->push_back(1);
}
else
{
@ -103,29 +98,16 @@ protected:
static_cast<ColumnType &>(column).getData().push_back(x);
}
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const override
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
}
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
PaddedPODArray<UInt8> * null_map) const override
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
FieldType x;
readCSV(x, istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
FieldType x;
readCSV(x, istr);
static_cast<ColumnType &>(column).getData().push_back(x);
}
};
@ -143,83 +125,53 @@ public:
void deserializeTextEscaped(IColumn & column, ReadBuffer & istr) const override {}
void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override {}
void deserializeTextQuoted(IColumn & column, ReadBuffer & istr) const override {}
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override {}
void deserializeTextJSON(IColumn & column, ReadBuffer & istr) const override {}
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override {}
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const override {}
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override {}
protected:
void serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const PaddedPODArray<UInt8> * null_map) const override {}
void deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr, PaddedPODArray<UInt8> * null_map) const override {}
void serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr, const PaddedPODArray<UInt8> * null_map) const override {}
void deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter, PaddedPODArray<UInt8> * null_map) const override {}
};
template <typename FType>
inline void IDataTypeNumber<FType>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const
inline void IDataTypeNumber<FType>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
}
template <>
inline void IDataTypeNumber<Int64>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const
inline void IDataTypeNumber<Int64>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
{
writeChar('"', ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeChar('"', ostr);
}
template <>
inline void IDataTypeNumber<UInt64>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const
inline void IDataTypeNumber<UInt64>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
{
writeChar('"', ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeChar('"', ostr);
}
writeChar('"', ostr);
writeText(static_cast<const ColumnType &>(column).getData()[row_num], ostr);
writeChar('"', ostr);
}
template <>
inline void IDataTypeNumber<Float32>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const
inline void IDataTypeNumber<Float32>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
auto x = static_cast<const ColumnType &>(column).getData()[row_num];
if (likely(std::isfinite(x)))
writeText(x, ostr);
else
{
auto x = static_cast<const ColumnType &>(column).getData()[row_num];
if (likely(std::isfinite(x)))
writeText(x, ostr);
else
writeCString(NullSymbol::JSON::name, ostr);
}
writeCString(NullSymbol::JSON::name, ostr);
}
template <>
inline void IDataTypeNumber<Float64>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const PaddedPODArray<UInt8> * null_map) const
inline void IDataTypeNumber<Float64>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
auto x = static_cast<const ColumnType &>(column).getData()[row_num];
if (likely(std::isfinite(x)))
writeText(x, ostr);
else
{
auto x = static_cast<const ColumnType &>(column).getData()[row_num];
if (likely(std::isfinite(x)))
writeText(x, ostr);
else
writeCString(NullSymbol::JSON::name, ostr);
}
writeCString(NullSymbol::JSON::name, ostr);
}
template <typename FType>

View File

@ -188,14 +188,12 @@ void DataTypeAggregateFunction::deserializeTextQuoted(IColumn & column, ReadBuff
deserializeFromString(function, column, s);
}
void DataTypeAggregateFunction::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeAggregateFunction::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
writeJSONString(serializeToString(function, column, row_num), ostr);
}
void DataTypeAggregateFunction::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeAggregateFunction::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
String s;
readJSONString(s, istr);
@ -207,14 +205,12 @@ void DataTypeAggregateFunction::serializeTextXML(const IColumn & column, size_t
writeXMLString(serializeToString(function, column, row_num), ostr);
}
void DataTypeAggregateFunction::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeAggregateFunction::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
writeCSV(serializeToString(function, column, row_num), ostr);
}
void DataTypeAggregateFunction::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeAggregateFunction::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
String s;
readCSV(s, istr, delimiter);

View File

@ -262,13 +262,6 @@ void deserializeTextInternal(IColumn & column, ReadBuffer & istr, Reader && read
offsets.push_back((offsets.empty() ? 0 : offsets.back()) + size);
}
void insertEmptyArray(IColumn & column)
{
ColumnArray & column_array = static_cast<ColumnArray &>(column);
ColumnArray::Offsets_t & offsets = column_array.getOffsets();
offsets.push_back((offsets.empty() ? 0 : offsets.back()));
}
}
void DataTypeArray::deserializeTextQuotedInternal(IColumn & column, ReadBuffer & istr) const
@ -306,40 +299,30 @@ void DataTypeArray::deserializeTextQuoted(IColumn & column, ReadBuffer & istr) c
}
void DataTypeArray::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeArray::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
const ColumnArray & column_array = static_cast<const ColumnArray &>(column);
const ColumnArray::Offsets_t & offsets = column_array.getOffsets();
size_t offset = row_num == 0 ? 0 : offsets[row_num - 1];
size_t next_offset = offsets[row_num];
const IColumn & nested_column = column_array.getData();
writeChar('[', ostr);
for (size_t i = offset; i < next_offset; ++i)
{
const ColumnArray & column_array = static_cast<const ColumnArray &>(column);
const ColumnArray::Offsets_t & offsets = column_array.getOffsets();
size_t offset = row_num == 0 ? 0 : offsets[row_num - 1];
size_t next_offset = offsets[row_num];
const IColumn & nested_column = column_array.getData();
writeChar('[', ostr);
for (size_t i = offset; i < next_offset; ++i)
{
if (i != offset)
writeChar(',', ostr);
nested->serializeTextJSON(nested_column, i, ostr, null_map);
}
writeChar(']', ostr);
if (i != offset)
writeChar(',', ostr);
nested->serializeTextJSON(nested_column, i, ostr);
}
writeChar(']', ostr);
}
void DataTypeArray::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeArray::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
insertEmptyArray(column);
else
deserializeTextInternal(column, istr, [&](IColumn & nested_column) { nested->deserializeTextJSON(nested_column, istr); });
deserializeTextInternal(column, istr, [&](IColumn & nested_column) { nested->deserializeTextJSON(nested_column, istr); });
}
@ -364,36 +347,24 @@ void DataTypeArray::serializeTextXML(const IColumn & column, size_t row_num, Wri
}
void DataTypeArray::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeArray::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::Quoted::name, ostr);
else
/// Хорошего способа сериализовать массив в CSV нет. Поэтому сериализуем его в строку, а затем полученную строку запишем в CSV.
String s;
{
/// Хорошего способа сериализовать массив в CSV нет. Поэтому сериализуем его в строку, а затем полученную строку запишем в CSV.
String s;
{
WriteBufferFromString wb(s);
serializeTextInternal(column, row_num, wb);
}
writeCSV(s, ostr);
WriteBufferFromString wb(s);
serializeTextInternal(column, row_num, wb);
}
writeCSV(s, ostr);
}
void DataTypeArray::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeArray::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
if (NullSymbol::Deserializer<NullSymbol::Quoted>::execute(column, istr, null_map))
insertEmptyArray(column);
else
{
String s;
readCSV(s, istr, delimiter);
ReadBufferFromString rb(s);
deserializeTextQuotedInternal(column, rb);
}
String s;
readCSV(s, istr, delimiter);
ReadBufferFromString rb(s);
deserializeTextQuotedInternal(column, rb);
}

View File

@ -171,13 +171,9 @@ void DataTypeEnum<Type>::deserializeTextQuoted(IColumn & column, ReadBuffer & is
}
template <typename Type>
void DataTypeEnum<Type>::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeEnum<Type>::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
writeJSONString(getNameForValue(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeJSONString(getNameForValue(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
}
template <typename Type>
@ -187,47 +183,25 @@ void DataTypeEnum<Type>::serializeTextXML(const IColumn & column, size_t row_num
}
template <typename Type>
void DataTypeEnum<Type>::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeEnum<Type>::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
std::string name;
readJSONString(name, istr);
static_cast<ColumnType &>(column).getData().push_back(getValue(StringRef(name)));
}
std::string name;
readJSONString(name, istr);
static_cast<ColumnType &>(column).getData().push_back(getValue(StringRef(name)));
}
template <typename Type>
void DataTypeEnum<Type>::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeEnum<Type>::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
writeCSVString(getNameForValue(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
writeCSVString(getNameForValue(static_cast<const ColumnType &>(column).getData()[row_num]), ostr);
}
template <typename Type>
void DataTypeEnum<Type>::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeEnum<Type>::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
{
FieldType default_val = get<FieldType>(getDefault());
static_cast<ColumnType &>(column).getData().push_back(default_val);
}
else
{
std::string name;
readCSVString(name, istr, delimiter);
static_cast<ColumnType &>(column).getData().push_back(getValue(StringRef(name)));
}
std::string name;
readCSVString(name, istr, delimiter);
static_cast<ColumnType &>(column).getData().push_back(getValue(StringRef(name)));
}
template <typename Type>

View File

@ -141,13 +141,6 @@ static inline void read(const DataTypeFixedString & self, IColumn & column, Read
}
}
void insertEmptyString(const DataTypeFixedString & self, IColumn & column)
{
ColumnFixedString::Chars_t & data = typeid_cast<ColumnFixedString &>(column).getChars();
size_t prev_size = data.size();
data.resize_fill(prev_size + self.getN());
}
}
void DataTypeFixedString::deserializeTextEscaped(IColumn & column, ReadBuffer & istr) const
@ -169,26 +162,16 @@ void DataTypeFixedString::deserializeTextQuoted(IColumn & column, ReadBuffer & i
}
void DataTypeFixedString::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeFixedString::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
{
const char * pos = reinterpret_cast<const char *>(&static_cast<const ColumnFixedString &>(column).getChars()[n * row_num]);
writeJSONString(pos, pos + n, ostr);
}
const char * pos = reinterpret_cast<const char *>(&static_cast<const ColumnFixedString &>(column).getChars()[n * row_num]);
writeJSONString(pos, pos + n, ostr);
}
void DataTypeFixedString::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeFixedString::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
insertEmptyString(*this, column);
else
read(*this, column, [&istr](ColumnFixedString::Chars_t & data) { readJSONStringInto(data, istr); });
read(*this, column, [&istr](ColumnFixedString::Chars_t & data) { readJSONStringInto(data, istr); });
}
@ -199,26 +182,16 @@ void DataTypeFixedString::serializeTextXML(const IColumn & column, size_t row_nu
}
void DataTypeFixedString::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeFixedString::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
{
const char * pos = reinterpret_cast<const char *>(&static_cast<const ColumnFixedString &>(column).getChars()[n * row_num]);
writeCSVString(pos, pos + n, ostr);
}
const char * pos = reinterpret_cast<const char *>(&static_cast<const ColumnFixedString &>(column).getChars()[n * row_num]);
writeCSVString(pos, pos + n, ostr);
}
void DataTypeFixedString::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeFixedString::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
insertEmptyString(*this, column);
else
read(*this, column, [&istr](ColumnFixedString::Chars_t & data) { readCSVStringInto(data, istr); });
read(*this, column, [&istr](ColumnFixedString::Chars_t & data) { readCSVStringInto(data, istr); });
}

View File

@ -121,14 +121,12 @@ void DataTypeNull::deserializeTextQuoted(IColumn & column, ReadBuffer & istr) co
assertString(NullSymbol::Quoted::name, istr);
}
void DataTypeNull::serializeTextCSVImpl(const IColumn & column, size_t row_num,
WriteBuffer & ostr, const NullValuesByteMap * null_map) const
void DataTypeNull::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
writeCString(NullSymbol::CSV::name, ostr);
}
void DataTypeNull::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr,
const char delimiter, NullValuesByteMap * null_map) const
void DataTypeNull::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
assertString(NullSymbol::CSV::name, istr);
}
@ -138,14 +136,12 @@ void DataTypeNull::serializeText(const IColumn & column, size_t row_num, WriteBu
writeCString(NullSymbol::Plain::name, ostr);
}
void DataTypeNull::serializeTextJSONImpl(const IColumn & column, size_t row_num,
WriteBuffer & ostr, const NullValuesByteMap * null_map) const
void DataTypeNull::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
writeCString(NullSymbol::JSON::name, ostr);
}
void DataTypeNull::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeNull::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
assertString(NullSymbol::JSON::name, istr);
}

View File

@ -142,26 +142,34 @@ void DataTypeNullable::deserializeTextQuoted(IColumn & column, ReadBuffer & istr
nested_data_type.get()->deserializeTextQuoted(*(col->getNestedColumn().get()), istr);
}
void DataTypeNullable::serializeTextCSVImpl(const IColumn & column, size_t row_num,
WriteBuffer & ostr, const NullValuesByteMap * null_map) const
void DataTypeNullable::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
const ColumnNullable * col = typeid_cast<const ColumnNullable *>(&column);
if (col == nullptr)
throw Exception{"Discrepancy between data type and column type", ErrorCodes::LOGICAL_ERROR};
const ColumnUInt8 & content = static_cast<const ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
nested_data_type.get()->serializeTextCSV(*(col->getNestedColumn().get()), row_num, ostr, &content.getData());
const auto & null_map = content.getData();
if (isNullValue(&null_map, row_num))
writeCString(NullSymbol::Quoted::name, ostr);
else
nested_data_type.get()->serializeTextCSV(*(col->getNestedColumn().get()), row_num, ostr);
}
void DataTypeNullable::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr,
const char delimiter, NullValuesByteMap * null_map) const
void DataTypeNullable::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
ColumnNullable * col = typeid_cast<ColumnNullable *>(&column);
if (col == nullptr)
throw Exception{"Discrepancy between data type and column type", ErrorCodes::LOGICAL_ERROR};
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
nested_data_type.get()->deserializeTextCSV(*(col->getNestedColumn().get()), istr, delimiter, &content.getData());
auto & null_map = content.getData();
if (NullSymbol::Deserializer<NullSymbol::Quoted>::execute(column, istr, &null_map))
col->insertDefault();
else
nested_data_type.get()->deserializeTextCSV(*(col->getNestedColumn().get()), istr, delimiter);
}
void DataTypeNullable::serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
@ -179,26 +187,34 @@ void DataTypeNullable::serializeText(const IColumn & column, size_t row_num, Wri
nested_data_type.get()->serializeText(*(col->getNestedColumn().get()), row_num, ostr);
}
void DataTypeNullable::serializeTextJSONImpl(const IColumn & column, size_t row_num,
WriteBuffer & ostr, const NullValuesByteMap * null_map) const
void DataTypeNullable::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
const ColumnNullable * col = typeid_cast<const ColumnNullable *>(&column);
if (col == nullptr)
throw Exception{"Discrepancy between data type and column type", ErrorCodes::LOGICAL_ERROR};
const ColumnUInt8 & content = static_cast<const ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
nested_data_type.get()->serializeTextJSON(*(col->getNestedColumn().get()), row_num, ostr, &content.getData());
const auto & null_map = content.getData();
if (isNullValue(&null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
nested_data_type.get()->serializeTextJSON(*(col->getNestedColumn().get()), row_num, ostr);
}
void DataTypeNullable::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeNullable::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
ColumnNullable * col = typeid_cast<ColumnNullable *>(&column);
if (col == nullptr)
throw Exception{"Discrepancy between data type and column type", ErrorCodes::LOGICAL_ERROR};
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
nested_data_type.get()->deserializeTextJSON(*(col->getNestedColumn().get()), istr, &content.getData());
auto & null_map = content.getData();
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, &null_map))
col->insertDefault();
else
nested_data_type.get()->deserializeTextJSON(*(col->getNestedColumn().get()), istr);
}
void DataTypeNullable::serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const

View File

@ -250,16 +250,6 @@ static inline void read(IColumn & column, ReadBuffer & istr, Reader && reader)
}
}
void insertEmptyString(IColumn & column)
{
ColumnString & column_string = static_cast<ColumnString &>(column);
ColumnString::Chars_t & data = column_string.getChars();
ColumnString::Offsets_t & offsets = column_string.getOffsets();
data.push_back(0);
offsets.push_back(data.size());
}
}
void DataTypeString::deserializeTextEscaped(IColumn & column, ReadBuffer & istr) const
@ -280,23 +270,15 @@ void DataTypeString::deserializeTextQuoted(IColumn & column, ReadBuffer & istr)
}
void DataTypeString::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeString::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
writeJSONString(static_cast<const ColumnString &>(column).getDataAt(row_num), ostr);
writeJSONString(static_cast<const ColumnString &>(column).getDataAt(row_num), ostr);
}
void DataTypeString::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeString::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
insertEmptyString(column);
else
read(column, istr, [&](ColumnString::Chars_t & data) { readJSONStringInto(data, istr); });
read(column, istr, [&](ColumnString::Chars_t & data) { readJSONStringInto(data, istr); });
}
@ -306,23 +288,15 @@ void DataTypeString::serializeTextXML(const IColumn & column, size_t row_num, Wr
}
void DataTypeString::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeString::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
writeCSVString<>(static_cast<const ColumnString &>(column).getDataAt(row_num), ostr);
writeCSVString<>(static_cast<const ColumnString &>(column).getDataAt(row_num), ostr);
}
void DataTypeString::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeString::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
if (NullSymbol::Deserializer<NullSymbol::CSV>::execute(column, istr, null_map))
insertEmptyString(column);
else
read(column, istr, [&](ColumnString::Chars_t & data) { readCSVStringInto(data, istr); });
read(column, istr, [&](ColumnString::Chars_t & data) { readCSVStringInto(data, istr); });
}

View File

@ -145,46 +145,36 @@ void DataTypeTuple::deserializeTextQuoted(IColumn & column, ReadBuffer & istr) c
deserializeText(column, istr);
}
void DataTypeTuple::serializeTextJSONImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeTuple::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::JSON::name, ostr);
else
writeChar('[', ostr);
for (const auto i : ext::range(0, ext::size(elems)))
{
writeChar('[', ostr);
for (const auto i : ext::range(0, ext::size(elems)))
{
if (i != 0)
writeChar(',', ostr);
elems[i]->serializeTextJSON(extractElementColumn(column, i), row_num, ostr, null_map);
}
writeChar(']', ostr);
if (i != 0)
writeChar(',', ostr);
elems[i]->serializeTextJSON(extractElementColumn(column, i), row_num, ostr);
}
writeChar(']', ostr);
}
void DataTypeTuple::deserializeTextJSONImpl(IColumn & column, ReadBuffer & istr,
NullValuesByteMap * null_map) const
void DataTypeTuple::deserializeTextJSON(IColumn & column, ReadBuffer & istr) const
{
if (!NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
const size_t size = elems.size();
assertChar('[', istr);
deserializeSafe(elems, column, istr, [&]
{
const size_t size = elems.size();
assertChar('[', istr);
deserializeSafe(elems, column, istr, [&]
for (const auto i : ext::range(0, size))
{
for (const auto i : ext::range(0, size))
{
skipWhitespaceIfAny(istr);
if (i != 0)
assertChar(',', istr);
elems[i]->deserializeTextJSON(extractElementColumn(column, i), istr, null_map);
}
});
skipWhitespaceIfAny(istr);
if (i != 0)
assertChar(',', istr);
elems[i]->deserializeTextJSON(extractElementColumn(column, i), istr);
}
});
skipWhitespaceIfAny(istr);
assertChar(']', istr);
}
skipWhitespaceIfAny(istr);
assertChar(']', istr);
}
void DataTypeTuple::serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
@ -199,42 +189,32 @@ void DataTypeTuple::serializeTextXML(const IColumn & column, size_t row_num, Wri
writeCString("</tuple>", ostr);
}
void DataTypeTuple::serializeTextCSVImpl(const IColumn & column, size_t row_num, WriteBuffer & ostr,
const NullValuesByteMap * null_map) const
void DataTypeTuple::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
if (isNullValue(null_map, row_num))
writeCString(NullSymbol::CSV::name, ostr);
else
for (const auto i : ext::range(0, ext::size(elems)))
{
for (const auto i : ext::range(0, ext::size(elems)))
{
if (i != 0)
writeChar(',', ostr);
elems[i]->serializeTextCSV(extractElementColumn(column, i), row_num, ostr, null_map);
}
if (i != 0)
writeChar(',', ostr);
elems[i]->serializeTextCSV(extractElementColumn(column, i), row_num, ostr);
}
}
void DataTypeTuple::deserializeTextCSVImpl(IColumn & column, ReadBuffer & istr, const char delimiter,
NullValuesByteMap * null_map) const
void DataTypeTuple::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const char delimiter) const
{
if (!NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, null_map))
deserializeSafe(elems, column, istr, [&]
{
deserializeSafe(elems, column, istr, [&]
const size_t size = elems.size();
for (const auto i : ext::range(0, size))
{
const size_t size = elems.size();
for (const auto i : ext::range(0, size))
if (i != 0)
{
if (i != 0)
{
skipWhitespaceIfAny(istr);
assertChar(delimiter, istr);
skipWhitespaceIfAny(istr);
}
elems[i]->deserializeTextCSV(extractElementColumn(column, i), istr, delimiter, null_map);
skipWhitespaceIfAny(istr);
assertChar(delimiter, istr);
skipWhitespaceIfAny(istr);
}
});
}
elems[i]->deserializeTextCSV(extractElementColumn(column, i), istr, delimiter);
}
});
}
void DataTypeTuple::serializeBinary(const IColumn & column, WriteBuffer & ostr, size_t offset, size_t limit) const