2022-09-08 16:37:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromFile.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class InputFormatErrorsLogger
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct ErrorEntry
|
|
|
|
{
|
|
|
|
time_t time;
|
|
|
|
size_t offset;
|
|
|
|
String reason;
|
|
|
|
String raw_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
InputFormatErrorsLogger(const ContextPtr & context);
|
|
|
|
|
2022-09-13 07:06:22 +00:00
|
|
|
virtual ~InputFormatErrorsLogger();
|
2022-09-08 16:37:18 +00:00
|
|
|
|
|
|
|
virtual void logError(ErrorEntry entry);
|
|
|
|
void logErrorImpl(ErrorEntry entry);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Block header;
|
|
|
|
|
|
|
|
String errors_file_path;
|
|
|
|
std::shared_ptr<WriteBufferFromFile> write_buf;
|
|
|
|
OutputFormatPtr writer;
|
|
|
|
|
|
|
|
String database;
|
|
|
|
String table;
|
|
|
|
};
|
|
|
|
|
|
|
|
using InputFormatErrorsLoggerPtr = std::shared_ptr<InputFormatErrorsLogger>;
|
|
|
|
|
|
|
|
class ParallelInputFormatErrorsLogger : public InputFormatErrorsLogger
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ParallelInputFormatErrorsLogger(const ContextPtr & context) : InputFormatErrorsLogger(context) { }
|
|
|
|
|
|
|
|
~ParallelInputFormatErrorsLogger() override;
|
|
|
|
|
|
|
|
void logError(ErrorEntry entry) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::mutex write_mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|