2016-07-07 01:57:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/IBlockOutputStream.h>
|
|
|
|
#include <DataStreams/SquashingTransform.h>
|
2016-07-07 01:57:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Merging consecutive blocks of stream to specified minimum size.
|
|
|
|
*/
|
|
|
|
class SquashingBlockOutputStream : public IBlockOutputStream
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
SquashingBlockOutputStream(BlockOutputStreamPtr & dst, size_t min_block_size_rows, size_t min_block_size_bytes);
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2018-02-19 00:45:32 +00:00
|
|
|
Block getHeader() const override { return output->getHeader(); }
|
2017-04-01 07:20:54 +00:00
|
|
|
void write(const Block & block) override;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void flush() override;
|
|
|
|
void writePrefix() override;
|
|
|
|
void writeSuffix() override;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-07-12 00:41:14 +00:00
|
|
|
/// Don't write blocks less than specified size even when flush method was called by user.
|
|
|
|
void disableFlush() { disable_flush = true; }
|
|
|
|
|
2016-07-07 01:57:48 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockOutputStreamPtr output;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
SquashingTransform transform;
|
|
|
|
bool all_written = false;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
void finalize();
|
2017-07-12 00:41:14 +00:00
|
|
|
|
|
|
|
bool disable_flush = false;
|
2016-07-07 01:57:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|