ClickHouse/dbms/include/DB/DataStreams/IBlockOutputStream.h
2015-10-29 23:38:37 +03:00

60 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <boost/noncopyable.hpp>
#include <Poco/SharedPtr.h>
#include <DB/Core/Block.h>
#include <DB/Core/Row.h>
#include <DB/Storages/IStorage.h>
namespace DB
{
using Poco::SharedPtr;
/** Интерфейс потока для записи данных в БД или в сеть, или в консоль и т. п.
*/
class IBlockOutputStream : private boost::noncopyable
{
public:
IBlockOutputStream() {}
/** Записать блок.
*/
virtual void write(const Block & block) = 0;
/** Записать что-нибудь перед началом всех данных или после конца всех данных.
*/
virtual void writePrefix() {}
virtual void writeSuffix() {}
/** Сбросить имеющиеся буферы для записи.
*/
virtual void flush() {}
/** Методы для установки дополнительной информации для вывода в поддерживающих её форматах.
*/
virtual void setRowsBeforeLimit(size_t rows_before_limit) {}
virtual void setTotals(const Block & totals) {}
virtual void setExtremes(const Block & extremes) {}
/** Выставлять такой Content-Type при отдаче по HTTP.
*/
virtual String getContentType() const { return "text/plain; charset=UTF-8"; }
virtual ~IBlockOutputStream() {}
/** Не давать изменить таблицу, пока жив поток блоков.
*/
void addTableLock(const IStorage::TableStructureReadLockPtr & lock) { table_locks.push_back(lock); }
protected:
IStorage::TableStructureReadLocks table_locks;
};
}