1 | #pragma once |
2 | |
3 | #include <Interpreters/SystemLog.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | struct PartLogElement |
10 | { |
11 | enum Type |
12 | { |
13 | NEW_PART = 1, |
14 | MERGE_PARTS = 2, |
15 | DOWNLOAD_PART = 3, |
16 | REMOVE_PART = 4, |
17 | MUTATE_PART = 5, |
18 | MOVE_PART = 6, |
19 | }; |
20 | |
21 | Type event_type = NEW_PART; |
22 | |
23 | time_t event_time = 0; |
24 | UInt64 duration_ms = 0; |
25 | |
26 | String database_name; |
27 | String table_name; |
28 | String part_name; |
29 | String partition_id; |
30 | String path_on_disk; |
31 | |
32 | /// Size of the part |
33 | UInt64 rows = 0; |
34 | |
35 | /// Size of files in filesystem |
36 | UInt64 bytes_compressed_on_disk = 0; |
37 | |
38 | /// Makes sense for merges and mutations. |
39 | Strings source_part_names; |
40 | UInt64 bytes_uncompressed = 0; |
41 | UInt64 rows_read = 0; |
42 | UInt64 bytes_read_uncompressed = 0; |
43 | |
44 | /// Was the operation successful? |
45 | UInt16 error = 0; |
46 | String exception; |
47 | |
48 | static std::string name() { return "PartLog" ; } |
49 | |
50 | static Block createBlock(); |
51 | void appendToBlock(Block & block) const; |
52 | }; |
53 | |
54 | struct MergeTreeDataPart; |
55 | |
56 | |
57 | /// Instead of typedef - to allow forward declaration. |
58 | class PartLog : public SystemLog<PartLogElement> |
59 | { |
60 | using SystemLog<PartLogElement>::SystemLog; |
61 | |
62 | using MutableDataPartPtr = std::shared_ptr<MergeTreeDataPart>; |
63 | using MutableDataPartsVector = std::vector<MutableDataPartPtr>; |
64 | |
65 | public: |
66 | /// Add a record about creation of new part. |
67 | static bool addNewPart(Context & context, const MutableDataPartPtr & part, UInt64 elapsed_ns, |
68 | const ExecutionStatus & execution_status = {}); |
69 | static bool addNewParts(Context & context, const MutableDataPartsVector & parts, UInt64 elapsed_ns, |
70 | const ExecutionStatus & execution_status = {}); |
71 | }; |
72 | |
73 | } |
74 | |