ClickHouse/dbms/include/DB/DataStreams/IRowOutputStream.h

64 lines
1.8 KiB
C++
Raw Normal View History

2011-10-24 12:10:59 +00:00
#pragma once
2010-03-04 19:20:28 +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;
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
*/
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
*/
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. */
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. */
virtual void flush() {}
2016-08-13 01:57:35 +00:00
/** Methods to set additional information for output in formats, that support it.
*/
virtual void setRowsBeforeLimit(size_t rows_before_limit) {}
virtual void setTotals(const Block & totals) {}
virtual void setExtremes(const Block & extremes) {}
/** 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() {}
};
using RowOutputStreamPtr = std::shared_ptr<IRowOutputStream>;
2010-03-04 19:20:28 +00:00
2011-10-24 12:10:59 +00:00
}