2011-08-28 02:22:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
2013-01-07 00:57:43 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
class Block;
|
2016-08-17 03:29:26 +00:00
|
|
|
struct Progress;
|
2016-08-13 01:57:35 +00:00
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
class TableStructureReadLock;
|
|
|
|
using TableStructureReadLockPtr = std::shared_ptr<TableStructureReadLock>;
|
|
|
|
using TableStructureReadLocks = std::vector<TableStructureReadLockPtr>;
|
|
|
|
|
|
|
|
struct Progress;
|
|
|
|
|
2011-08-28 02:22:23 +00:00
|
|
|
|
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
|
|
|
*/
|
2013-01-07 00:57:43 +00:00
|
|
|
class IBlockOutputStream : private boost::noncopyable
|
2010-03-04 19:20:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-03-19 10:45:13 +00:00
|
|
|
IBlockOutputStream() {}
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Write block.
|
2010-03-04 19:20:28 +00:00
|
|
|
*/
|
|
|
|
virtual void write(const Block & block) = 0;
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Write or do something before all data or after all data.
|
2011-10-31 06:37:12 +00:00
|
|
|
*/
|
|
|
|
virtual void writePrefix() {}
|
|
|
|
virtual void writeSuffix() {}
|
2014-08-14 20:27:41 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Flush output buffers if any.
|
2014-08-14 20:27:41 +00:00
|
|
|
*/
|
|
|
|
virtual void flush() {}
|
2016-05-28 12:22:22 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Methods to set additional information for output in formats, that support it.
|
2013-09-01 04:55:41 +00:00
|
|
|
*/
|
2013-05-22 14:57:43 +00:00
|
|
|
virtual void setRowsBeforeLimit(size_t rows_before_limit) {}
|
2013-09-01 04:55:41 +00:00
|
|
|
virtual void setTotals(const Block & totals) {}
|
2013-09-07 02:03:13 +00:00
|
|
|
virtual void setExtremes(const Block & extremes) {}
|
2011-10-31 06:37:12 +00:00
|
|
|
|
2016-08-17 03:29:26 +00:00
|
|
|
/** Notify about progress. Method could be called from different threads.
|
|
|
|
* Passed value are delta, that must be summarized.
|
|
|
|
*/
|
|
|
|
virtual void onProgress(const Progress & progress) {}
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Content-Type to set when sending HTTP response.
|
2015-10-29 20:38:37 +00:00
|
|
|
*/
|
2017-01-21 04:24:28 +00:00
|
|
|
virtual std::string getContentType() const { return "text/plain; charset=UTF-8"; }
|
2015-10-29 20:38:37 +00:00
|
|
|
|
2010-03-04 19:20:28 +00:00
|
|
|
virtual ~IBlockOutputStream() {}
|
2014-03-19 10:45:13 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Don't let to alter table while instance of stream is alive.
|
2014-03-19 10:45:13 +00:00
|
|
|
*/
|
2017-01-21 04:24:28 +00:00
|
|
|
void addTableLock(const TableStructureReadLockPtr & lock) { table_locks.push_back(lock); }
|
2016-05-28 12:22:22 +00:00
|
|
|
|
2013-01-23 17:38:03 +00:00
|
|
|
protected:
|
2017-01-21 04:24:28 +00:00
|
|
|
TableStructureReadLocks table_locks;
|
2010-03-04 19:20:28 +00:00
|
|
|
};
|
|
|
|
|
2016-05-28 12:22:22 +00:00
|
|
|
using BlockOutputStreamPtr = std::shared_ptr<IBlockOutputStream>;
|
|
|
|
|
2011-08-28 02:22:23 +00:00
|
|
|
}
|