ClickHouse/src/Interpreters/PartLog.h

101 lines
2.7 KiB
C++
Raw Normal View History

#pragma once
#include <Storages/MergeTree/MergeTreeDataPartType.h>
#include <Interpreters/SystemLog.h>
#include <Core/NamesAndTypes.h>
#include <Core/NamesAndAliases.h>
#include <Storages/MergeTree/MergeType.h>
namespace DB
{
struct PartLogElement
{
enum Type
{
NEW_PART = 1,
MERGE_PARTS = 2,
DOWNLOAD_PART = 3,
REMOVE_PART = 4,
MUTATE_PART = 5,
2019-09-03 11:32:25 +00:00
MOVE_PART = 6,
};
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,
};
String query_id;
Type event_type = NEW_PART;
MergeReasonType merge_reason = NOT_A_MERGE;
time_t event_time = 0;
Decimal64 event_time_microseconds = 0;
UInt64 duration_ms = 0;
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;
MergeTreeDataPartType part_type;
/// 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.
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-08-28 18:25:40 +00:00
/// Was the operation successful?
UInt16 error = 0;
String exception;
static std::string name() { return "PartLog"; }
static MergeReasonType getMergeReasonType(MergeType merge_type);
static NamesAndTypesList getNamesAndTypes();
static NamesAndAliases getNamesAndAliases() { return {}; }
void appendToBlock(MutableColumns & columns) const;
static const char * getCustomColumnList() { return nullptr; }
};
2019-10-10 16:30:30 +00:00
class IMergeTreeDataPart;
/// Instead of typedef - to allow forward declaration.
class PartLog : public SystemLog<PartLogElement>
{
using SystemLog<PartLogElement>::SystemLog;
2019-10-10 16:30:30 +00:00
using MutableDataPartPtr = std::shared_ptr<IMergeTreeDataPart>;
using MutableDataPartsVector = std::vector<MutableDataPartPtr>;
public:
/// Add a record about creation of new part.
static bool addNewPart(ContextPtr context, const MutableDataPartPtr & part, UInt64 elapsed_ns,
const ExecutionStatus & execution_status = {});
static bool addNewParts(ContextPtr context, const MutableDataPartsVector & parts, UInt64 elapsed_ns,
const ExecutionStatus & execution_status = {});
};
}