|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <Storages/MergeTree/BackgroundProcessList.h> |
| 4 | +#include <Interpreters/StorageID.h> |
| 5 | +#include <Common/Stopwatch.h> |
| 6 | +#include <Common/CurrentMetrics.h> |
| 7 | +#include <Common/ThreadStatus.h> |
| 8 | +#include <Poco/URI.h> |
| 9 | +#include <boost/noncopyable.hpp> |
| 10 | + |
| 11 | +namespace CurrentMetrics |
| 12 | +{ |
| 13 | + extern const Metric Export; |
| 14 | +} |
| 15 | + |
| 16 | +namespace DB |
| 17 | +{ |
| 18 | + |
| 19 | +struct ExportInfo |
| 20 | +{ |
| 21 | + String source_database; |
| 22 | + String source_table; |
| 23 | + String destination_database; |
| 24 | + String destination_table; |
| 25 | + String part_name; |
| 26 | + String destination_file_path; |
| 27 | + UInt64 rows_read; |
| 28 | + UInt64 total_rows_to_read; |
| 29 | + UInt64 total_size_bytes_compressed; |
| 30 | + UInt64 total_size_bytes_uncompressed; |
| 31 | + UInt64 bytes_read_uncompressed; |
| 32 | + UInt64 memory_usage; |
| 33 | + UInt64 peak_memory_usage; |
| 34 | + time_t create_time = 0; |
| 35 | + Float64 elapsed; |
| 36 | +}; |
| 37 | + |
| 38 | +struct ExportsListElement : private boost::noncopyable |
| 39 | +{ |
| 40 | + const StorageID source_table_id; |
| 41 | + const StorageID destination_table_id; |
| 42 | + const UInt64 part_size; |
| 43 | + const String part_name; |
| 44 | + const String destination_file_path; |
| 45 | + UInt64 rows_read {0}; |
| 46 | + UInt64 total_rows_to_read {0}; |
| 47 | + UInt64 total_size_bytes_compressed {0}; |
| 48 | + UInt64 total_size_bytes_uncompressed {0}; |
| 49 | + UInt64 bytes_read_uncompressed {0}; |
| 50 | + time_t create_time {0}; |
| 51 | + Float64 elapsed {0}; |
| 52 | + |
| 53 | + Stopwatch watch; |
| 54 | + ThreadGroupPtr thread_group; |
| 55 | + |
| 56 | + ExportsListElement( |
| 57 | + const StorageID & source_table_id_, |
| 58 | + const StorageID & destination_table_id_, |
| 59 | + UInt64 part_size_, |
| 60 | + const String & part_name_, |
| 61 | + const String & destination_file_path_, |
| 62 | + UInt64 total_rows_to_read_, |
| 63 | + UInt64 total_size_bytes_compressed_, |
| 64 | + UInt64 total_size_bytes_uncompressed_, |
| 65 | + time_t create_time_, |
| 66 | + const ContextPtr & context); |
| 67 | + |
| 68 | + ~ExportsListElement(); |
| 69 | + |
| 70 | + ExportInfo getInfo() const; |
| 71 | + |
| 72 | + UInt64 getMemoryUsage() const; |
| 73 | + UInt64 getPeakMemoryUsage() const; |
| 74 | +}; |
| 75 | + |
| 76 | + |
| 77 | +class ExportsList final : public BackgroundProcessList<ExportsListElement, ExportInfo> |
| 78 | +{ |
| 79 | +private: |
| 80 | + using Parent = BackgroundProcessList<ExportsListElement, ExportInfo>; |
| 81 | + |
| 82 | +public: |
| 83 | + ExportsList() |
| 84 | + : Parent(CurrentMetrics::Export) |
| 85 | + {} |
| 86 | +}; |
| 87 | + |
| 88 | +using ExportsListEntry = BackgroundProcessListEntry<ExportsListElement, ExportInfo>; |
| 89 | + |
| 90 | +} |
0 commit comments