1 | #pragma once |
2 | |
3 | #include <memory> |
4 | #include <cstdint> |
5 | #include <boost/noncopyable.hpp> |
6 | #include <Core/Types.h> |
7 | |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | class Block; |
13 | class IColumn; |
14 | class IDataType; |
15 | struct Progress; |
16 | |
17 | |
18 | /** Interface of stream for writing data by rows (for example: for output to terminal). |
19 | */ |
20 | class IRowOutputStream : private boost::noncopyable |
21 | { |
22 | public: |
23 | |
24 | /** Write a row. |
25 | * Default implementation calls methods to write single values and delimiters |
26 | * (except delimiter between rows (writeRowBetweenDelimiter())). |
27 | */ |
28 | virtual void write(const Block & block, size_t row_num); |
29 | |
30 | /** Write single value. */ |
31 | virtual void writeField(const IColumn & column, const IDataType & type, size_t row_num); |
32 | |
33 | /** Write delimiter. */ |
34 | virtual void writeFieldDelimiter() {} /// delimiter between values |
35 | virtual void writeRowStartDelimiter() {} /// delimiter before each row |
36 | virtual void writeRowEndDelimiter() {} /// delimiter after each row |
37 | virtual void writeRowBetweenDelimiter() {} /// delimiter between rows |
38 | virtual void writePrefix() {} /// delimiter before resultset |
39 | virtual void writeSuffix() {} /// delimiter after resultset |
40 | |
41 | /** Flush output buffers if any. */ |
42 | virtual void flush() {} |
43 | |
44 | /** Methods to set additional information for output in formats, that support it. |
45 | */ |
46 | virtual void setRowsBeforeLimit(size_t /*rows_before_limit*/) {} |
47 | virtual void setTotals(const Block & /*totals*/) {} |
48 | virtual void setExtremes(const Block & /*extremes*/) {} |
49 | |
50 | /** Notify about progress. Method could be called from different threads. |
51 | * Passed value are delta, that must be summarized. |
52 | */ |
53 | virtual void onProgress(const Progress & /*progress*/) {} |
54 | |
55 | /** Content-Type to set when sending HTTP response. */ |
56 | virtual String getContentType() const { return "text/plain; charset=UTF-8" ; } |
57 | |
58 | virtual ~IRowOutputStream() {} |
59 | }; |
60 | |
61 | using RowOutputStreamPtr = std::shared_ptr<IRowOutputStream>; |
62 | |
63 | } |
64 | |