ClickHouse/dbms/src/DataStreams/SquashingBlockOutputStream.h

39 lines
906 B
C++
Raw Normal View History

2016-07-07 01:57:48 +00:00
#pragma once
#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:
SquashingBlockOutputStream(BlockOutputStreamPtr & dst, size_t min_block_size_rows, size_t min_block_size_bytes);
2016-07-07 01:57:48 +00:00
Block getHeader() const override { return output->getHeader(); }
void write(const Block & block) override;
2016-07-07 01:57:48 +00:00
void flush() override;
void writePrefix() override;
void writeSuffix() override;
2016-07-07 01:57:48 +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:
BlockOutputStreamPtr output;
2016-07-07 01:57:48 +00:00
SquashingTransform transform;
bool all_written = false;
2016-07-07 01:57:48 +00:00
void finalize();
bool disable_flush = false;
2016-07-07 01:57:48 +00:00
};
}