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;
|
2022-08-25 18:44:40 +00:00
|
|
|
struct StorageSnapshot;
|
|
|
|
using StorageSnapshotPtr = std::shared_ptr<StorageSnapshot>;
|
2017-06-25 00:01:10 +00:00
|
|
|
|
|
|
|
|
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_,
|
2022-02-01 10:36:51 +00:00
|
|
|
StorageMetadataPtr metadata_snapshot_,
|
2021-02-10 14:12:49 +00:00
|
|
|
size_t max_parts_per_block_,
|
2022-02-01 10:36:51 +00:00
|
|
|
ContextPtr context_);
|
|
|
|
|
|
|
|
~MergeTreeSink() override;
|
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;
|
2022-02-01 10:36:51 +00:00
|
|
|
void onFinish() override;
|
2014-03-13 12:48:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
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;
|
2022-08-25 18:44:40 +00:00
|
|
|
StorageSnapshotPtr storage_snapshot;
|
2022-01-03 23:04:56 +00:00
|
|
|
uint64_t chunk_dedup_seqnum = 0; /// input chunk ordinal number in case of dedup token
|
2022-02-01 10:36:51 +00:00
|
|
|
|
|
|
|
/// We can delay processing for previous chunk and start writing a new one.
|
|
|
|
struct DelayedChunk;
|
|
|
|
std::unique_ptr<DelayedChunk> delayed_chunk;
|
|
|
|
|
|
|
|
void finishDelayedChunk();
|
2014-03-13 12:48:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|