2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/System/StorageSystemMerges.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeArray.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
|
|
|
#include <DataStreams/OneBlockInputStream.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Storages/MergeTree/MergeList.h>
|
2015-04-16 06:12:35 +00:00
|
|
|
|
2014-09-10 11:34:26 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2015-01-21 03:56:28 +00:00
|
|
|
StorageSystemMerges::StorageSystemMerges(const std::string & name)
|
2017-04-01 07:20:54 +00:00
|
|
|
: name{name}
|
|
|
|
, columns{
|
|
|
|
{ "database", std::make_shared<DataTypeString>() },
|
|
|
|
{ "table", std::make_shared<DataTypeString>() },
|
|
|
|
{ "elapsed", std::make_shared<DataTypeFloat64>() },
|
|
|
|
{ "progress", std::make_shared<DataTypeFloat64>() },
|
|
|
|
{ "num_parts", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "source_part_names", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>()) },
|
|
|
|
{ "result_part_name", std::make_shared<DataTypeString>() },
|
|
|
|
{ "total_size_bytes_compressed", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "total_size_marks", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "bytes_read_uncompressed", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "rows_read", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "bytes_written_uncompressed", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "rows_written", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "columns_written", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "memory_usage", std::make_shared<DataTypeUInt64>() },
|
|
|
|
{ "thread_number", std::make_shared<DataTypeUInt64>() },
|
|
|
|
}
|
2014-09-10 11:34:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-21 03:56:28 +00:00
|
|
|
StoragePtr StorageSystemMerges::create(const std::string & name)
|
2014-09-10 11:34:26 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
return make_shared(name);
|
2014-09-10 11:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemMerges::read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2017-05-25 01:12:41 +00:00
|
|
|
const ASTPtr & query,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
const size_t max_block_size,
|
|
|
|
const unsigned)
|
2014-09-10 11:34:26 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
check(column_names);
|
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
2014-09-10 11:34:26 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Block block = getSampleBlock();
|
2014-09-10 11:34:26 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (const auto & merge : context.getMergeList().get())
|
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
block.getByPosition(i++).column->insert(merge.database);
|
|
|
|
block.getByPosition(i++).column->insert(merge.table);
|
|
|
|
block.getByPosition(i++).column->insert(merge.elapsed);
|
|
|
|
block.getByPosition(i++).column->insert(std::min(1., merge.progress)); /// little cheat
|
|
|
|
block.getByPosition(i++).column->insert(merge.num_parts);
|
|
|
|
block.getByPosition(i++).column->insert(merge.source_part_names);
|
|
|
|
block.getByPosition(i++).column->insert(merge.result_part_name);
|
|
|
|
block.getByPosition(i++).column->insert(merge.total_size_bytes_compressed);
|
|
|
|
block.getByPosition(i++).column->insert(merge.total_size_marks);
|
|
|
|
block.getByPosition(i++).column->insert(merge.bytes_read_uncompressed);
|
|
|
|
block.getByPosition(i++).column->insert(merge.rows_read);
|
|
|
|
block.getByPosition(i++).column->insert(merge.bytes_written_uncompressed);
|
|
|
|
block.getByPosition(i++).column->insert(merge.rows_written);
|
|
|
|
block.getByPosition(i++).column->insert(merge.columns_written);
|
|
|
|
block.getByPosition(i++).column->insert(merge.memory_usage);
|
|
|
|
block.getByPosition(i++).column->insert(merge.thread_number);
|
|
|
|
}
|
2014-09-10 11:34:26 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return BlockInputStreams{1, std::make_shared<OneBlockInputStream>(block)};
|
2014-09-10 11:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|