mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-24 18:50:49 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include <IO/WriteHelpers.h>
|
|
#include <IO/WriteBufferValidUTF8.h>
|
|
#include <Processors/Formats/Impl/JSONEachRowWithProgressRowOutputFormat.h>
|
|
#include <Formats/FormatFactory.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
|
|
void JSONEachRowWithProgressRowOutputFormat::writeRowStartDelimiter()
|
|
{
|
|
writeCString("{\"row\":{", out);
|
|
}
|
|
|
|
void JSONEachRowWithProgressRowOutputFormat::writeRowEndDelimiter()
|
|
{
|
|
writeCString("}}\n", out);
|
|
field_number = 0;
|
|
}
|
|
|
|
void JSONEachRowWithProgressRowOutputFormat::onProgress(const Progress & value)
|
|
{
|
|
progress.incrementPiecewiseAtomically(value);
|
|
writeCString("{\"progress\":", out);
|
|
progress.writeJSON(out);
|
|
writeCString("}\n", out);
|
|
}
|
|
|
|
|
|
void registerOutputFormatProcessorJSONEachRowWithProgress(FormatFactory & factory)
|
|
{
|
|
factory.registerOutputFormatProcessor("JSONEachRowWithProgress", [](
|
|
WriteBuffer & buf,
|
|
const Block & sample,
|
|
FormatFactory::WriteCallback callback,
|
|
const FormatSettings & format_settings)
|
|
{
|
|
return std::make_shared<JSONEachRowWithProgressRowOutputFormat>(buf, sample, callback, format_settings);
|
|
});
|
|
}
|
|
|
|
}
|