2018-05-24 01:02:16 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Processors/ISource.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class ReadBuffer;
|
|
|
|
|
|
|
|
|
|
/** Input format is a source, that reads data from ReadBuffer.
|
|
|
|
|
*/
|
|
|
|
|
class IInputFormat : public ISource
|
|
|
|
|
{
|
2019-02-19 18:41:18 +00:00
|
|
|
|
protected:
|
2019-02-05 13:01:40 +00:00
|
|
|
|
|
|
|
|
|
/// Skip GCC warning: ‘maybe_unused’ attribute ignored
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wattributes"
|
|
|
|
|
|
2018-06-04 18:31:46 +00:00
|
|
|
|
ReadBuffer & in [[maybe_unused]];
|
2018-05-24 01:02:16 +00:00
|
|
|
|
|
2019-02-05 13:01:40 +00:00
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
2018-05-24 01:02:16 +00:00
|
|
|
|
public:
|
2019-11-26 23:46:19 +00:00
|
|
|
|
IInputFormat(Block header, ReadBuffer & in_);
|
|
|
|
|
|
|
|
|
|
/** In some usecase (hello Kafka) we need to read a lot of tiny streams in exactly the same format.
|
|
|
|
|
* The recreating of parser for each small stream takes too long, so we introduce a method
|
2019-12-26 15:59:38 +00:00
|
|
|
|
* resetParser() which allow to reset the state of parser to continue reading of
|
2019-11-26 23:46:19 +00:00
|
|
|
|
* source stream w/o recreating that.
|
|
|
|
|
* That should be called after current buffer was fully read.
|
|
|
|
|
*/
|
|
|
|
|
virtual void resetParser();
|
2019-07-30 18:48:40 +00:00
|
|
|
|
|
|
|
|
|
virtual const BlockMissingValues & getMissingValues() const
|
|
|
|
|
{
|
|
|
|
|
static const BlockMissingValues none;
|
|
|
|
|
return none;
|
|
|
|
|
}
|
2020-02-07 13:16:51 +00:00
|
|
|
|
|
|
|
|
|
size_t getCurrentUnitNumber() const { return current_unit_number; }
|
|
|
|
|
void setCurrentUnitNumber(size_t current_unit_number_) { current_unit_number = current_unit_number_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/// Number of currently parsed chunk (if parallel parsing is enabled)
|
|
|
|
|
size_t current_unit_number = 0;
|
2018-05-24 01:02:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|