2018-03-30 19:25:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2020-02-27 16:47:40 +00:00
|
|
|
#include <Disks/IDisk.h>
|
2019-01-10 17:06:27 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreePartInfo.h>
|
2020-02-27 16:47:40 +00:00
|
|
|
#include <Storages/MutationCommands.h>
|
2021-12-14 20:06:34 +00:00
|
|
|
#include <Common/TransactionID.h>
|
2018-03-30 19:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// A mutation entry for non-replicated MergeTree storage engines.
|
2019-09-04 17:26:53 +00:00
|
|
|
/// Stores information about mutation in file mutation_*.txt.
|
2018-03-30 19:25:37 +00:00
|
|
|
struct MergeTreeMutationEntry
|
|
|
|
{
|
|
|
|
time_t create_time = 0;
|
|
|
|
MutationCommands commands;
|
2018-07-11 12:43:55 +00:00
|
|
|
|
2020-02-27 16:47:40 +00:00
|
|
|
DiskPtr disk;
|
2018-07-11 12:43:55 +00:00
|
|
|
String path_prefix;
|
|
|
|
String file_name;
|
|
|
|
bool is_temp = false;
|
|
|
|
|
2021-11-19 16:51:03 +00:00
|
|
|
UInt64 block_number = 0;
|
2018-07-11 12:43:55 +00:00
|
|
|
|
2019-01-10 17:06:27 +00:00
|
|
|
String latest_failed_part;
|
|
|
|
MergeTreePartInfo latest_failed_part_info;
|
|
|
|
time_t latest_fail_time = 0;
|
|
|
|
String latest_fail_reason;
|
|
|
|
|
2021-12-14 20:06:34 +00:00
|
|
|
/// ID of transaction which has created mutation.
|
|
|
|
TransactionID tid = Tx::PrehistoricTID;
|
2022-03-18 11:01:26 +00:00
|
|
|
/// CSN of transaction which has created mutation
|
|
|
|
/// or UnknownCSN if it's not committed (yet) or RolledBackCSN if it's rolled back or PrehistoricCSN if there is no transaction.
|
2022-03-17 17:26:18 +00:00
|
|
|
CSN csn = Tx::UnknownCSN;
|
2021-12-14 20:06:34 +00:00
|
|
|
|
2018-07-11 12:43:55 +00:00
|
|
|
/// Create a new entry and write it to a temporary file.
|
2021-12-14 20:06:34 +00:00
|
|
|
MergeTreeMutationEntry(MutationCommands commands_, DiskPtr disk, const String & path_prefix_, UInt64 tmp_number,
|
|
|
|
const TransactionID & tid_);
|
|
|
|
|
2018-07-31 12:34:34 +00:00
|
|
|
MergeTreeMutationEntry(const MergeTreeMutationEntry &) = delete;
|
|
|
|
MergeTreeMutationEntry(MergeTreeMutationEntry &&) = default;
|
2018-07-11 12:43:55 +00:00
|
|
|
|
|
|
|
/// Commit entry and rename it to a permanent file.
|
2021-11-19 16:51:03 +00:00
|
|
|
void commit(UInt64 block_number_);
|
2018-07-11 12:43:55 +00:00
|
|
|
|
|
|
|
void removeFile();
|
|
|
|
|
2022-03-17 17:26:18 +00:00
|
|
|
void writeCSN(CSN csn_);
|
|
|
|
|
2021-11-19 16:51:03 +00:00
|
|
|
static String versionToFileName(UInt64 block_number_);
|
|
|
|
static UInt64 tryParseFileName(const String & file_name_);
|
|
|
|
static UInt64 parseFileName(const String & file_name_);
|
|
|
|
|
2018-07-11 12:43:55 +00:00
|
|
|
/// Load an existing entry.
|
2020-02-27 16:47:40 +00:00
|
|
|
MergeTreeMutationEntry(DiskPtr disk_, const String & path_prefix_, const String & file_name_);
|
2018-07-11 12:43:55 +00:00
|
|
|
|
|
|
|
~MergeTreeMutationEntry();
|
2018-03-30 19:25:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|