1#pragma once
2
3#include <boost/noncopyable.hpp>
4#include <memory>
5#include <string>
6
7#include <Columns/IColumn.h>
8
9
10namespace DB
11{
12
13/// Contains extra information about read data.
14struct RowReadExtension
15{
16 /// IRowInputStream.read() output. It contains non zero for columns that actually read from the source and zero otherwise.
17 /// It's used to attach defaults for partially filled rows.
18 /// Can be empty, this means that all columns are read.
19 std::vector<UInt8> read_columns;
20};
21
22/** Interface of stream, that allows to read data by rows.
23 */
24class IRowInputStream : private boost::noncopyable
25{
26public:
27 /** Read next row and append it to the columns.
28 * If no more rows - return false.
29 */
30 virtual bool read(MutableColumns & columns, RowReadExtension & extra) = 0;
31
32 virtual void readPrefix() {} /// delimiter before begin of result
33 virtual void readSuffix() {} /// delimiter after end of result
34
35 /// Skip data until next row.
36 /// This is intended for text streams, that allow skipping of errors.
37 /// By default - throws not implemented exception.
38 virtual bool allowSyncAfterError() const { return false; }
39 virtual void syncAfterError();
40
41 /// In case of parse error, try to roll back and parse last one or two rows very carefully
42 /// and collect as much as possible diagnostic information about error.
43 /// If not implemented, returns empty string.
44 virtual std::string getDiagnosticInfo() { return {}; }
45
46 virtual ~IRowInputStream() {}
47};
48
49using RowInputStreamPtr = std::shared_ptr<IRowInputStream>;
50
51}
52