2017-03-07 17:13:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-05-25 14:54:49 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeDataPartType.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/SystemLog.h>
|
2022-01-10 19:01:41 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
|
|
|
#include <Core/NamesAndAliases.h>
|
2022-05-04 17:16:42 +00:00
|
|
|
#include <Storages/MergeTree/MergeType.h>
|
2017-03-07 17:13:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
struct PartLogElement
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
NEW_PART = 1,
|
|
|
|
MERGE_PARTS = 2,
|
|
|
|
DOWNLOAD_PART = 3,
|
|
|
|
REMOVE_PART = 4,
|
2018-05-25 19:44:14 +00:00
|
|
|
MUTATE_PART = 5,
|
2019-09-03 11:32:25 +00:00
|
|
|
MOVE_PART = 6,
|
2017-04-01 07:20:54 +00:00
|
|
|
};
|
2017-03-07 17:13:54 +00:00
|
|
|
|
2022-05-04 17:16:42 +00:00
|
|
|
enum MergeReasonType
|
|
|
|
{
|
|
|
|
/// merge_reason is relevant only for event_type = 'MERGE_PARTS', in other cases it is NOT_A_MERGE
|
|
|
|
NOT_A_MERGE = 1,
|
|
|
|
/// Just regular merge
|
|
|
|
REGULAR_MERGE = 2,
|
|
|
|
/// Merge assigned to delete some data from parts (with TTLMergeSelector)
|
|
|
|
TTL_DELETE_MERGE = 3,
|
|
|
|
/// Merge with recompression
|
|
|
|
TTL_RECOMPRESS_MERGE = 4,
|
|
|
|
};
|
|
|
|
|
2020-12-30 16:37:08 +00:00
|
|
|
String query_id;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Type event_type = NEW_PART;
|
2022-05-04 17:16:42 +00:00
|
|
|
MergeReasonType merge_reason = NOT_A_MERGE;
|
2017-03-07 17:13:54 +00:00
|
|
|
|
2018-01-23 22:56:46 +00:00
|
|
|
time_t event_time = 0;
|
2021-02-03 08:14:46 +00:00
|
|
|
Decimal64 event_time_microseconds = 0;
|
2018-01-23 22:56:46 +00:00
|
|
|
UInt64 duration_ms = 0;
|
2017-03-07 17:13:54 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
String database_name;
|
|
|
|
String table_name;
|
|
|
|
String part_name;
|
2018-09-13 15:57:51 +00:00
|
|
|
String partition_id;
|
2022-03-10 15:44:19 +00:00
|
|
|
String disk_name;
|
2019-09-03 11:32:25 +00:00
|
|
|
String path_on_disk;
|
2018-01-23 22:56:46 +00:00
|
|
|
|
2022-05-25 14:54:49 +00:00
|
|
|
MergeTreeDataPartType part_type;
|
|
|
|
|
2018-01-23 22:56:46 +00:00
|
|
|
/// Size of the part
|
|
|
|
UInt64 rows = 0;
|
|
|
|
|
|
|
|
/// Size of files in filesystem
|
|
|
|
UInt64 bytes_compressed_on_disk = 0;
|
|
|
|
|
2018-08-28 18:25:40 +00:00
|
|
|
/// Makes sense for merges and mutations.
|
2018-01-23 22:56:46 +00:00
|
|
|
Strings source_part_names;
|
|
|
|
UInt64 bytes_uncompressed = 0;
|
|
|
|
UInt64 rows_read = 0;
|
|
|
|
UInt64 bytes_read_uncompressed = 0;
|
2020-03-19 11:31:21 +00:00
|
|
|
UInt64 peak_memory_usage = 0;
|
2018-01-23 22:56:46 +00:00
|
|
|
|
2018-08-28 18:25:40 +00:00
|
|
|
/// Was the operation successful?
|
2018-01-23 22:56:46 +00:00
|
|
|
UInt16 error = 0;
|
|
|
|
String exception;
|
2017-03-07 17:13:54 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
static std::string name() { return "PartLog"; }
|
2017-03-07 17:13:54 +00:00
|
|
|
|
2022-05-04 17:16:42 +00:00
|
|
|
static MergeReasonType getMergeReasonType(MergeType merge_type);
|
2021-06-28 11:42:21 +00:00
|
|
|
static NamesAndTypesList getNamesAndTypes();
|
|
|
|
static NamesAndAliases getNamesAndAliases() { return {}; }
|
2020-05-21 20:15:18 +00:00
|
|
|
void appendToBlock(MutableColumns & columns) const;
|
2022-04-17 21:49:39 +00:00
|
|
|
static const char * getCustomColumnList() { return nullptr; }
|
2017-03-07 17:13:54 +00:00
|
|
|
};
|
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
class IMergeTreeDataPart;
|
2017-06-25 00:01:10 +00:00
|
|
|
|
2017-03-07 17:13:54 +00:00
|
|
|
|
|
|
|
/// Instead of typedef - to allow forward declaration.
|
|
|
|
class PartLog : public SystemLog<PartLogElement>
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
using SystemLog<PartLogElement>::SystemLog;
|
2017-06-25 00:01:10 +00:00
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
using MutableDataPartPtr = std::shared_ptr<IMergeTreeDataPart>;
|
2018-05-21 13:49:54 +00:00
|
|
|
using MutableDataPartsVector = std::vector<MutableDataPartPtr>;
|
|
|
|
|
2017-06-25 00:01:10 +00:00
|
|
|
public:
|
|
|
|
/// Add a record about creation of new part.
|
2021-04-10 23:33:54 +00:00
|
|
|
static bool addNewPart(ContextPtr context, const MutableDataPartPtr & part, UInt64 elapsed_ns,
|
2018-05-21 13:49:54 +00:00
|
|
|
const ExecutionStatus & execution_status = {});
|
2021-04-10 23:33:54 +00:00
|
|
|
static bool addNewParts(ContextPtr context, const MutableDataPartsVector & parts, UInt64 elapsed_ns,
|
2018-05-21 13:49:54 +00:00
|
|
|
const ExecutionStatus & execution_status = {});
|
2017-03-07 17:13:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|