mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 21:51:57 +00:00
b079dacfd1
* Added part_log * first_test * filter and hits_res * Add renamer and drawer * Add columns database and table into PartLog * Add normal way to get table_name and database_name from part * improve drawer * add stats for random size parts * Merge converter and drawer * make drawer more informative * add new data * add new data * new data * add long range stats * for checking best way * Add add_parts script * Good style for global merge * delete commented code * Fixed spaces to tabs * Note that Stopwatch is started automatically. * Style * Update StorageMergeTree.cpp * Update StorageReplicatedMergeTree.cpp * Switch act_time_ms to duration_ms * Added ability to disable part_log * fixed getPartLog * fix usage getPartLog * fix
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#pragma once
|
||
|
||
#include <DB/IO/WriteBufferFromFile.h>
|
||
#include <DB/IO/CompressedWriteBuffer.h>
|
||
|
||
#include <DB/Columns/ColumnsNumber.h>
|
||
|
||
#include <DB/Interpreters/sortBlock.h>
|
||
#include <DB/Interpreters/Context.h>
|
||
|
||
#include <DB/Storages/MergeTree/MergeTreeData.h>
|
||
|
||
|
||
namespace DB
|
||
{
|
||
|
||
struct BlockWithDateInterval
|
||
{
|
||
Block block;
|
||
UInt16 min_date = std::numeric_limits<UInt16>::max(); /// For further updating, see updateDates method.
|
||
UInt16 max_date = std::numeric_limits<UInt16>::min();
|
||
|
||
BlockWithDateInterval() = default;
|
||
BlockWithDateInterval(const Block & block_, UInt16 min_date_, UInt16 max_date_)
|
||
: block(block_), min_date(min_date_), max_date(max_date_) {}
|
||
|
||
void updateDates(UInt16 date)
|
||
{
|
||
if (date < min_date)
|
||
min_date = date;
|
||
|
||
if (date > max_date)
|
||
max_date = date;
|
||
}
|
||
};
|
||
|
||
using BlocksWithDateIntervals = std::list<BlockWithDateInterval>;
|
||
|
||
/** Записывает новые куски с данными в merge-дерево.
|
||
*/
|
||
class MergeTreeDataWriter
|
||
{
|
||
public:
|
||
MergeTreeDataWriter(MergeTreeData & data_, Context & context_) : data(data_), context(context_), log(&Logger::get(data.getLogName() + " (Writer)")) {}
|
||
|
||
/** Split the block to blocks, each of them must be written as separate part.
|
||
* (split rows by months)
|
||
* Works deterministically: if same block was passed, function will return same result in same order.
|
||
*/
|
||
BlocksWithDateIntervals splitBlockIntoParts(const Block & block);
|
||
|
||
/** All rows must correspond to same month.
|
||
* 'temp_index' - value for 'left' and 'right' for new part. Could be changed later at rename.
|
||
* Returns part with name starting with 'tmp_', yet not added to MergeTreeData.
|
||
*/
|
||
MergeTreeData::MutableDataPartPtr writeTempPart(BlockWithDateInterval & block, Int64 temp_index);
|
||
|
||
private:
|
||
MergeTreeData & data;
|
||
Context & context;
|
||
|
||
Logger * log;
|
||
};
|
||
|
||
}
|