2011-10-24 12:10:59 +00:00
|
|
|
#pragma once
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2016-05-28 12:22:22 +00:00
|
|
|
#include <memory>
|
2016-08-13 01:57:35 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <boost/noncopyable.hpp>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Types.h>
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
class Block;
|
|
|
|
class IColumn;
|
|
|
|
class IDataType;
|
2016-08-17 03:29:26 +00:00
|
|
|
struct Progress;
|
2016-08-13 01:57:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Interface of stream for writing data by rows (for example: for output to terminal).
|
2010-03-04 19:20:28 +00:00
|
|
|
*/
|
2013-01-07 00:57:43 +00:00
|
|
|
class IRowOutputStream : private boost::noncopyable
|
2010-03-04 19:20:28 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
/** Write a row.
|
|
|
|
* Default implementation calls methods to write single values and delimiters
|
|
|
|
* (except delimiter between rows (writeRowBetweenDelimiter())).
|
|
|
|
*/
|
|
|
|
virtual void write(const Block & block, size_t row_num);
|
|
|
|
|
|
|
|
/** Write single value. */
|
2019-02-22 13:51:25 +00:00
|
|
|
virtual void writeField(const IColumn & column, const IDataType & type, size_t row_num);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
/** Write delimiter. */
|
2018-06-03 17:43:56 +00:00
|
|
|
virtual void writeFieldDelimiter() {} /// delimiter between values
|
|
|
|
virtual void writeRowStartDelimiter() {} /// delimiter before each row
|
|
|
|
virtual void writeRowEndDelimiter() {} /// delimiter after each row
|
|
|
|
virtual void writeRowBetweenDelimiter() {} /// delimiter between rows
|
|
|
|
virtual void writePrefix() {} /// delimiter before resultset
|
|
|
|
virtual void writeSuffix() {} /// delimiter after resultset
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
/** Flush output buffers if any. */
|
|
|
|
virtual void flush() {}
|
|
|
|
|
|
|
|
/** Methods to set additional information for output in formats, that support it.
|
|
|
|
*/
|
2017-12-01 19:34:51 +00:00
|
|
|
virtual void setRowsBeforeLimit(size_t /*rows_before_limit*/) {}
|
|
|
|
virtual void setTotals(const Block & /*totals*/) {}
|
|
|
|
virtual void setExtremes(const Block & /*extremes*/) {}
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
/** Notify about progress. Method could be called from different threads.
|
|
|
|
* Passed value are delta, that must be summarized.
|
|
|
|
*/
|
2017-12-01 19:34:51 +00:00
|
|
|
virtual void onProgress(const Progress & /*progress*/) {}
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
/** Content-Type to set when sending HTTP response. */
|
|
|
|
virtual String getContentType() const { return "text/plain; charset=UTF-8"; }
|
|
|
|
|
|
|
|
virtual ~IRowOutputStream() {}
|
2010-03-04 19:20:28 +00:00
|
|
|
};
|
|
|
|
|
2016-05-28 12:22:22 +00:00
|
|
|
using RowOutputStreamPtr = std::shared_ptr<IRowOutputStream>;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2011-10-24 12:10:59 +00:00
|
|
|
}
|