ClickHouse/dbms/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

70 lines
1.6 KiB
C++

#pragma once
#include <DataStreams/IBlockOutputStream.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <Core/Types.h>
namespace Poco { class Logger; }
namespace zkutil
{
class ZooKeeper;
using ZooKeeperPtr = std::shared_ptr<ZooKeeper>;
}
namespace DB
{
class StorageReplicatedMergeTree;
class ReplicatedMergeTreeBlockOutputStream : public IBlockOutputStream
{
public:
ReplicatedMergeTreeBlockOutputStream(StorageReplicatedMergeTree & storage_,
size_t quorum_, size_t quorum_timeout_ms_, size_t max_parts_per_block_,
bool deduplicate_);
Block getHeader() const override;
void writePrefix() override;
void write(const Block & block) override;
/// For ATTACHing existing data on filesystem.
void writeExistingPart(MergeTreeData::MutableDataPartPtr & part);
/// For proper deduplication in MaterializedViews
bool lastBlockIsDuplicate() const
{
return last_block_is_duplicate;
}
private:
struct QuorumInfo
{
String status_path;
String is_active_node_value;
int is_active_node_version = -1;
int host_node_version = -1;
};
QuorumInfo quorum_info;
void checkQuorumPrecondition(zkutil::ZooKeeperPtr & zookeeper);
/// Rename temporary part and commit to ZooKeeper.
void commitPart(zkutil::ZooKeeperPtr & zookeeper, MergeTreeData::MutableDataPartPtr & part, const String & block_id);
StorageReplicatedMergeTree & storage;
size_t quorum;
size_t quorum_timeout_ms;
size_t max_parts_per_block;
bool deduplicate = true;
bool last_block_is_duplicate = false;
using Logger = Poco::Logger;
Logger * log;
};
}