mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
pass buffers explicitly
This commit is contained in:
parent
a24686d300
commit
31e0e5cec7
@ -103,9 +103,9 @@ void SerializationMap::serializeTextImpl(
|
|||||||
if (i != offset)
|
if (i != offset)
|
||||||
writeChar(',', ostr);
|
writeChar(',', ostr);
|
||||||
|
|
||||||
key_writer(key, nested_tuple.getColumn(0), i);
|
key_writer(ostr, key, nested_tuple.getColumn(0), i);
|
||||||
writeChar(':', ostr);
|
writeChar(':', ostr);
|
||||||
value_writer(value, nested_tuple.getColumn(1), i);
|
value_writer(ostr, value, nested_tuple.getColumn(1), i);
|
||||||
}
|
}
|
||||||
writeChar('}', ostr);
|
writeChar('}', ostr);
|
||||||
}
|
}
|
||||||
@ -145,13 +145,13 @@ void SerializationMap::deserializeTextImpl(IColumn & column, ReadBuffer & istr,
|
|||||||
if (*istr.position() == '}')
|
if (*istr.position() == '}')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
reader(key, key_column);
|
reader(istr, key, key_column);
|
||||||
skipWhitespaceIfAny(istr);
|
skipWhitespaceIfAny(istr);
|
||||||
assertChar(':', istr);
|
assertChar(':', istr);
|
||||||
|
|
||||||
++size;
|
++size;
|
||||||
skipWhitespaceIfAny(istr);
|
skipWhitespaceIfAny(istr);
|
||||||
reader(value, value_column);
|
reader(istr, value, value_column);
|
||||||
|
|
||||||
skipWhitespaceIfAny(istr);
|
skipWhitespaceIfAny(istr);
|
||||||
}
|
}
|
||||||
@ -167,9 +167,9 @@ void SerializationMap::deserializeTextImpl(IColumn & column, ReadBuffer & istr,
|
|||||||
|
|
||||||
void SerializationMap::serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const
|
void SerializationMap::serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const
|
||||||
{
|
{
|
||||||
auto writer = [&](const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
auto writer = [&settings](WriteBuffer & buf, const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
||||||
{
|
{
|
||||||
subcolumn_serialization->serializeTextQuoted(subcolumn, pos, ostr, settings);
|
subcolumn_serialization->serializeTextQuoted(subcolumn, pos, buf, settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
serializeTextImpl(column, row_num, ostr, writer, writer);
|
serializeTextImpl(column, row_num, ostr, writer, writer);
|
||||||
@ -178,34 +178,34 @@ void SerializationMap::serializeText(const IColumn & column, size_t row_num, Wri
|
|||||||
void SerializationMap::deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
|
void SerializationMap::deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
|
||||||
{
|
{
|
||||||
deserializeTextImpl(column, istr,
|
deserializeTextImpl(column, istr,
|
||||||
[&](const SerializationPtr & subcolumn_serialization, IColumn & subcolumn)
|
[&settings](ReadBuffer & buf, const SerializationPtr & subcolumn_serialization, IColumn & subcolumn)
|
||||||
{
|
{
|
||||||
subcolumn_serialization->deserializeTextQuoted(subcolumn, istr, settings);
|
subcolumn_serialization->deserializeTextQuoted(subcolumn, buf, settings);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerializationMap::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const
|
void SerializationMap::serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const
|
||||||
{
|
{
|
||||||
serializeTextImpl(column, row_num, ostr,
|
serializeTextImpl(column, row_num, ostr,
|
||||||
[&](const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
[&settings](WriteBuffer & buf, const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
||||||
{
|
{
|
||||||
/// We need to double-quote all keys (including integers) to produce valid JSON.
|
/// We need to double-quote all keys (including integers) to produce valid JSON.
|
||||||
WriteBufferFromOwnString str_buf;
|
WriteBufferFromOwnString str_buf;
|
||||||
subcolumn_serialization->serializeText(subcolumn, pos, str_buf, settings);
|
subcolumn_serialization->serializeText(subcolumn, pos, str_buf, settings);
|
||||||
writeJSONString(str_buf.str(), ostr, settings);
|
writeJSONString(str_buf.str(), buf, settings);
|
||||||
},
|
},
|
||||||
[&](const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
[&settings](WriteBuffer & buf, const SerializationPtr & subcolumn_serialization, const IColumn & subcolumn, size_t pos)
|
||||||
{
|
{
|
||||||
subcolumn_serialization->serializeTextJSON(subcolumn, pos, ostr, settings);
|
subcolumn_serialization->serializeTextJSON(subcolumn, pos, buf, settings);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerializationMap::deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
|
void SerializationMap::deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const
|
||||||
{
|
{
|
||||||
deserializeTextImpl(column, istr,
|
deserializeTextImpl(column, istr,
|
||||||
[&](const SerializationPtr & subcolumn_serialization, IColumn & subcolumn)
|
[&settings](ReadBuffer & buf, const SerializationPtr & subcolumn_serialization, IColumn & subcolumn)
|
||||||
{
|
{
|
||||||
subcolumn_serialization->deserializeTextJSON(subcolumn, istr, settings);
|
subcolumn_serialization->deserializeTextJSON(subcolumn, buf, settings);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user