SquashingBlockOutputStream.h 637 字节
Newer Older
A
Alexey Milovidov 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#pragma once

#include <DB/DataStreams/IBlockOutputStream.h>
#include <DB/DataStreams/SquashingTransform.h>


namespace DB
{

/** Merging consecutive blocks of stream to specified minimum size.
  */
class SquashingBlockOutputStream : public IBlockOutputStream
{
public:
	SquashingBlockOutputStream(BlockOutputStreamPtr & dst, size_t min_block_size_rows, size_t min_block_size_bytes);

	void write(const Block & block) override;

	void flush() override;
	void writePrefix() override;
	void writeSuffix() override;

private:
	BlockOutputStreamPtr output;

	SquashingTransform transform;
	bool all_written = false;

	void finalize();
};

}