2017-11-24 13:55:31 +00:00
|
|
|
#include "Progress.h"
|
2017-01-22 15:03:55 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/ReadBuffer.h>
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/ReadHelpers.h>
|
|
|
|
#include <IO/WriteHelpers.h>
|
2017-01-22 15:03:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2019-04-26 03:38:39 +00:00
|
|
|
void AllProgressValueImpl::read(ProgressValues & value, ReadBuffer & in, UInt64 /*server_revision*/)
|
2017-01-22 15:03:55 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t new_rows = 0;
|
|
|
|
size_t new_bytes = 0;
|
|
|
|
size_t new_total_rows = 0;
|
2019-04-25 11:25:49 +00:00
|
|
|
size_t new_write_rows = 0;
|
|
|
|
size_t new_write_bytes = 0;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
readVarUInt(new_rows, in);
|
|
|
|
readVarUInt(new_bytes, in);
|
2017-08-16 20:27:35 +00:00
|
|
|
readVarUInt(new_total_rows, in);
|
2019-04-25 11:25:49 +00:00
|
|
|
readVarUInt(new_write_rows, in);
|
|
|
|
readVarUInt(new_write_bytes, in);
|
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
value.rows = new_rows;
|
|
|
|
value.bytes = new_bytes;
|
|
|
|
value.total_rows = new_total_rows;
|
|
|
|
value.write_rows = new_write_rows;
|
|
|
|
value.write_bytes = new_write_bytes;
|
2019-04-25 11:25:49 +00:00
|
|
|
}
|
2017-01-22 15:03:55 +00:00
|
|
|
|
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
void AllProgressValueImpl::write(const ProgressValues & value, WriteBuffer & out, UInt64 /*client_revision*/)
|
2017-01-22 15:03:55 +00:00
|
|
|
{
|
2019-04-26 03:38:39 +00:00
|
|
|
writeVarUInt(value.rows, out);
|
|
|
|
writeVarUInt(value.bytes, out);
|
|
|
|
writeVarUInt(value.total_rows, out);
|
|
|
|
writeVarUInt(value.write_rows, out);
|
|
|
|
writeVarUInt(value.write_bytes, out);
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
void AllProgressValueImpl::writeJSON(const ProgressValues & value, WriteBuffer & out)
|
2017-01-22 15:03:55 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
/// Numbers are written in double quotes (as strings) to avoid loss of precision
|
|
|
|
/// of 64-bit integers after interpretation by JavaScript.
|
|
|
|
|
|
|
|
writeCString("{\"read_rows\":\"", out);
|
2019-04-26 03:38:39 +00:00
|
|
|
writeText(value.rows, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\",\"read_bytes\":\"", out);
|
2019-04-26 03:38:39 +00:00
|
|
|
writeText(value.bytes, out);
|
2019-04-25 11:25:49 +00:00
|
|
|
writeCString("\",\"write_rows\":\"", out);
|
2019-04-26 03:38:39 +00:00
|
|
|
writeText(value.write_rows, out);
|
2019-04-25 11:25:49 +00:00
|
|
|
writeCString("\",\"write_bytes\":\"", out);
|
2019-04-26 03:38:39 +00:00
|
|
|
writeText(value.write_bytes, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\",\"total_rows\":\"", out);
|
2019-04-26 03:38:39 +00:00
|
|
|
writeText(value.total_rows, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\"}", out);
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
void ReadProgressValueImpl::writeJSON(const ProgressValues & value, WriteBuffer & out)
|
|
|
|
{
|
|
|
|
/// Numbers are written in double quotes (as strings) to avoid loss of precision
|
|
|
|
/// of 64-bit integers after interpretation by JavaScript.
|
2018-03-09 23:04:26 +00:00
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
writeCString("{\"read_rows\":\"", out);
|
|
|
|
writeText(value.rows, out);
|
|
|
|
writeCString("\",\"read_bytes\":\"", out);
|
|
|
|
writeText(value.bytes, out);
|
|
|
|
writeCString("\",\"total_rows\":\"", out);
|
|
|
|
writeText(value.total_rows, out);
|
|
|
|
writeCString("\"}", out);
|
|
|
|
}
|
2018-03-09 23:04:26 +00:00
|
|
|
|
2019-04-26 03:38:39 +00:00
|
|
|
void WriteProgressValueImpl::writeJSON(const ProgressValues & value, WriteBuffer & out)
|
2018-03-09 23:04:26 +00:00
|
|
|
{
|
2019-04-26 03:38:39 +00:00
|
|
|
/// Numbers are written in double quotes (as strings) to avoid loss of precision
|
|
|
|
/// of 64-bit integers after interpretation by JavaScript.
|
|
|
|
|
|
|
|
writeCString("{\"write_rows\":\"", out);
|
|
|
|
writeText(value.write_rows, out);
|
|
|
|
writeCString("\",\"write_bytes\":\"", out);
|
|
|
|
writeText(value.write_bytes, out);
|
|
|
|
writeCString("\"}", out);
|
2018-03-09 23:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|