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
|
|
|
|
{
|
|
|
|
|
2018-03-09 23:04:26 +00:00
|
|
|
void ProgressValues::read(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;
|
2017-01-22 15:03:55 +00:00
|
|
|
|
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);
|
2017-01-22 15:03:55 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
rows = new_rows;
|
|
|
|
bytes = new_bytes;
|
|
|
|
total_rows = new_total_rows;
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-09 23:04:26 +00:00
|
|
|
void ProgressValues::write(WriteBuffer & out, UInt64 /*client_revision*/) const
|
2017-01-22 15:03:55 +00:00
|
|
|
{
|
2018-03-09 23:04:26 +00:00
|
|
|
writeVarUInt(rows, out);
|
|
|
|
writeVarUInt(bytes, out);
|
|
|
|
writeVarUInt(total_rows, out);
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-09 23:04:26 +00:00
|
|
|
void ProgressValues::writeJSON(WriteBuffer & out) const
|
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);
|
2018-03-09 23:04:26 +00:00
|
|
|
writeText(rows, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\",\"read_bytes\":\"", out);
|
2018-03-09 23:04:26 +00:00
|
|
|
writeText(bytes, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\",\"total_rows\":\"", out);
|
2018-03-09 23:04:26 +00:00
|
|
|
writeText(total_rows, out);
|
2017-04-01 07:20:54 +00:00
|
|
|
writeCString("\"}", out);
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2018-03-09 23:04:26 +00:00
|
|
|
|
|
|
|
void Progress::read(ReadBuffer & in, UInt64 server_revision)
|
|
|
|
{
|
|
|
|
ProgressValues values;
|
|
|
|
values.read(in, server_revision);
|
|
|
|
|
|
|
|
rows.store(values.rows, std::memory_order_relaxed);
|
|
|
|
bytes.store(values.bytes, std::memory_order_relaxed);
|
|
|
|
total_rows.store(values.total_rows, std::memory_order_relaxed);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Progress::write(WriteBuffer & out, UInt64 client_revision) const
|
|
|
|
{
|
|
|
|
getValues().write(out, client_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Progress::writeJSON(WriteBuffer & out) const
|
|
|
|
{
|
|
|
|
getValues().writeJSON(out);
|
|
|
|
}
|
|
|
|
|
2017-01-22 15:03:55 +00:00
|
|
|
}
|