2014-03-13 12:48:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-23 19:33:59 +00:00
|
|
|
#include <Processors/Sinks/SinkToStorage.h>
|
2020-06-16 15:51:29 +00:00
|
|
|
#include <Storages/StorageInMemoryMetadata.h>
|
2014-03-13 12:48:07 +00:00
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
|
2014-03-13 12:48:07 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-06-25 00:01:10 +00:00
|
|
|
class Block;
|
|
|
|
class StorageMergeTree;
|
|
|
|
|
|
|
|
|
2021-07-23 19:33:59 +00:00
|
|
|
class MergeTreeSink : public SinkToStorage
|
2014-03-13 12:48:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-07-23 19:33:59 +00:00
|
|
|
MergeTreeSink(
|
2021-02-10 14:12:49 +00:00
|
|
|
StorageMergeTree & storage_,
|
|
|
|
const StorageMetadataPtr metadata_snapshot_,
|
|
|
|
size_t max_parts_per_block_,
|
|
|
|
ContextPtr context_)
|
2021-07-26 10:08:40 +00:00
|
|
|
: SinkToStorage(metadata_snapshot_->getSampleBlock())
|
2021-07-23 19:33:59 +00:00
|
|
|
, storage(storage_)
|
2020-06-16 15:51:29 +00:00
|
|
|
, metadata_snapshot(metadata_snapshot_)
|
|
|
|
, max_parts_per_block(max_parts_per_block_)
|
2021-02-10 14:12:49 +00:00
|
|
|
, context(context_)
|
2020-06-26 11:30:23 +00:00
|
|
|
{
|
|
|
|
}
|
2014-03-13 12:48:07 +00:00
|
|
|
|
2021-07-23 19:33:59 +00:00
|
|
|
String getName() const override { return "MergeTreeSink"; }
|
|
|
|
void consume(Chunk chunk) override;
|
2021-07-26 14:47:29 +00:00
|
|
|
void onStart() override;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageMergeTree & storage;
|
2020-06-16 15:51:29 +00:00
|
|
|
StorageMetadataPtr metadata_snapshot;
|
2019-03-29 09:33:39 +00:00
|
|
|
size_t max_parts_per_block;
|
2021-02-10 14:12:49 +00:00
|
|
|
ContextPtr context;
|
2014-03-13 12:48:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|