2018-04-19 10:33:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/Exception.h>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <common/types.h>
|
2018-04-19 10:33:16 +00:00
|
|
|
#include <IO/WriteHelpers.h>
|
|
|
|
#include <Storages/MutationCommands.h>
|
2019-01-18 16:30:35 +00:00
|
|
|
#include <map>
|
2018-04-19 10:33:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ReadBuffer;
|
|
|
|
class WriteBuffer;
|
|
|
|
|
2020-02-13 16:16:09 +00:00
|
|
|
/// Mutation entry in /mutations path in zookeeper. This record contains information about blocks
|
|
|
|
/// in patitions. We will mutatate all parts with left number less than this numbers.
|
|
|
|
///
|
|
|
|
/// These entries processed separately from main replication /log, and produce other entries
|
2020-02-17 18:07:22 +00:00
|
|
|
/// -- MUTATE_PART in main replication log.
|
2018-04-19 10:33:16 +00:00
|
|
|
struct ReplicatedMergeTreeMutationEntry
|
|
|
|
{
|
|
|
|
void writeText(WriteBuffer & out) const;
|
|
|
|
void readText(ReadBuffer & in);
|
|
|
|
|
|
|
|
String toString() const;
|
2018-04-19 14:20:18 +00:00
|
|
|
static ReplicatedMergeTreeMutationEntry parse(const String & str, String znode_name);
|
2018-04-19 10:33:16 +00:00
|
|
|
|
2020-02-13 16:16:09 +00:00
|
|
|
/// Name of znode (mutation-xxxxxxx)
|
2018-04-19 10:33:16 +00:00
|
|
|
String znode_name;
|
|
|
|
|
2020-02-13 16:16:09 +00:00
|
|
|
/// Create time of znode
|
2018-04-19 10:33:16 +00:00
|
|
|
time_t create_time = 0;
|
2020-02-13 16:16:09 +00:00
|
|
|
|
|
|
|
/// Replica which initiated mutation
|
2018-04-19 10:33:16 +00:00
|
|
|
String source_replica;
|
|
|
|
|
2020-11-10 10:23:46 +00:00
|
|
|
/// Acquired block numbers
|
2020-02-13 16:16:09 +00:00
|
|
|
/// partition_id -> block_number
|
2020-11-10 10:23:46 +00:00
|
|
|
using BlockNumbersType = std::map<String, Int64>;
|
|
|
|
BlockNumbersType block_numbers;
|
2020-02-13 16:16:09 +00:00
|
|
|
|
|
|
|
/// Mutation commands which will give to MUTATE_PART entries
|
2018-04-19 10:33:16 +00:00
|
|
|
MutationCommands commands;
|
2020-01-31 19:30:33 +00:00
|
|
|
|
2020-02-13 16:16:09 +00:00
|
|
|
/// Version of metadata. Not equal to -1 only if this mutation
|
|
|
|
/// was created by ALTER MODIFY/DROP queries.
|
2020-01-31 19:30:33 +00:00
|
|
|
int alter_version = -1;
|
2020-02-17 16:33:05 +00:00
|
|
|
|
|
|
|
bool isAlterMutation() const { return alter_version != -1; }
|
2018-04-19 10:33:16 +00:00
|
|
|
};
|
|
|
|
|
2018-06-07 11:00:43 +00:00
|
|
|
using ReplicatedMergeTreeMutationEntryPtr = std::shared_ptr<const ReplicatedMergeTreeMutationEntry>;
|
|
|
|
|
2018-04-19 10:33:16 +00:00
|
|
|
}
|