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>
|
|
|
|
#include <DB/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:
|
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Write a row.
|
|
|
|
* Default implementation calls methods to write single values and delimiters
|
|
|
|
* (except delimiter between rows (writeRowBetweenDelimiter())).
|
2010-03-04 19:20:28 +00:00
|
|
|
*/
|
2016-02-16 16:39:39 +00:00
|
|
|
virtual void write(const Block & block, size_t row_num);
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Write single value. */
|
2016-02-16 16:39:39 +00:00
|
|
|
virtual void writeField(const IColumn & column, const IDataType & type, size_t row_num) = 0;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
2016-08-13 01:57:35 +00:00
|
|
|
/** Write delimiter. */
|
|
|
|
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
|
2010-03-04 19:20:28 +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-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
|
|
|
*/
|
|
|
|
virtual void setRowsBeforeLimit(size_t rows_before_limit) {}
|
|
|
|
virtual void setTotals(const Block & totals) {}
|
2013-09-07 02:03:13 +00:00
|
|
|
virtual void setExtremes(const Block & extremes) {}
|
2013-09-01 04:55:41 +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
|
|
|
virtual String getContentType() const { return "text/plain; charset=UTF-8"; }
|
|
|
|
|
2010-03-04 19:20:28 +00:00
|
|
|
virtual ~IRowOutputStream() {}
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|