ClickHouse/dbms/src/Formats/IRowOutputStream.h

64 lines
2.0 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 <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:
/** 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. */
virtual void writeField(const IColumn & column, const IDataType & type, size_t row_num) = 0;
/** 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
/** 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*/) {}
/** 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*/) {}
/** 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
};
using RowOutputStreamPtr = std::shared_ptr<IRowOutputStream>;
2010-03-04 19:20:28 +00:00
2011-10-24 12:10:59 +00:00
}