ClickHouse/dbms/DataStreams/IBlockOutputStream.h

71 lines
2.0 KiB
C++
Raw Normal View History

2011-08-28 02:22:23 +00:00
#pragma once
#include <Core/Block.h>
#include <DataStreams/IBlockStream_fwd.h>
2019-03-05 10:12:20 +00:00
#include <Storages/TableStructureLockHolder.h>
2010-03-04 19:20:28 +00:00
#include <boost/noncopyable.hpp>
#include <memory>
#include <string>
#include <vector>
2010-03-04 19:20:28 +00:00
namespace DB
{
struct Progress;
2016-08-13 01:57:35 +00:00
/** Interface of stream for writing data (into table, filesystem, network, terminal, etc.)
2010-03-04 19:20:28 +00:00
*/
class IBlockOutputStream : private boost::noncopyable
2010-03-04 19:20:28 +00:00
{
public:
IBlockOutputStream() {}
2010-03-04 19:20:28 +00:00
/** Get data structure of the stream in a form of "header" block (it is also called "sample block").
* Header block contains column names, data types, columns of size 0. Constant columns must have corresponding values.
* You must pass blocks of exactly this structure to the 'write' method.
*/
virtual Block getHeader() const = 0;
/** Write block.
*/
virtual void write(const Block & block) = 0;
2010-03-04 19:20:28 +00:00
/** Write or do something before all data or after all data.
*/
virtual void writePrefix() {}
virtual void writeSuffix() {}
/** Flush output buffers if any.
*/
virtual void flush() {}
/** Methods to set additional information for output in formats, that support it.
*/
2017-12-01 18:36:55 +00:00
virtual void setRowsBeforeLimit(size_t /*rows_before_limit*/) {}
virtual void setTotals(const Block & /*totals*/) {}
virtual void setExtremes(const Block & /*extremes*/) {}
2011-10-31 06:37:12 +00:00
/** Notify about progress. Method could be called from different threads.
* Passed value are delta, that must be summarized.
*/
2017-12-01 18:36:55 +00:00
virtual void onProgress(const Progress & /*progress*/) {}
/** Content-Type to set when sending HTTP response.
*/
virtual std::string getContentType() const { return "text/plain; charset=UTF-8"; }
2015-10-29 20:38:37 +00:00
virtual ~IBlockOutputStream() {}
/** Don't let to alter table while instance of stream is alive.
*/
void addTableLock(const TableStructureReadLockHolder & lock) { table_locks.push_back(lock); }
private:
std::vector<TableStructureReadLockHolder> table_locks;
2010-03-04 19:20:28 +00:00
};
2011-08-28 02:22:23 +00:00
}