2019-01-23 19:36:57 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-06-20 09:12:49 +00:00
|
|
|
#include "config_formats.h"
|
2019-01-25 20:02:03 +00:00
|
|
|
#if USE_PROTOBUF
|
|
|
|
|
2019-01-27 09:15:32 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <unordered_map>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <common/types.h>
|
2019-08-22 03:24:05 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2019-01-23 19:36:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace google
|
|
|
|
{
|
|
|
|
namespace protobuf
|
|
|
|
{
|
|
|
|
class Descriptor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class FormatSchemaInfo;
|
|
|
|
|
2019-02-26 19:51:42 +00:00
|
|
|
/** Keeps parsed google protobuf schemas parsed from files.
|
2019-01-23 19:36:57 +00:00
|
|
|
* This class is used to handle the "Protobuf" input/output formats.
|
|
|
|
*/
|
2019-08-22 03:24:05 +00:00
|
|
|
class ProtobufSchemas : private boost::noncopyable
|
2019-01-23 19:36:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-08-22 03:24:05 +00:00
|
|
|
static ProtobufSchemas & instance();
|
|
|
|
|
2019-01-23 19:36:57 +00:00
|
|
|
ProtobufSchemas();
|
2019-01-27 09:15:32 +00:00
|
|
|
~ProtobufSchemas();
|
2019-01-23 19:36:57 +00:00
|
|
|
|
|
|
|
/// Parses the format schema, then parses the corresponding proto file, and returns the descriptor of the message type.
|
|
|
|
/// The function never returns nullptr, it throws an exception if it cannot load or parse the file.
|
2019-01-27 09:15:32 +00:00
|
|
|
const google::protobuf::Descriptor * getMessageTypeForFormatSchema(const FormatSchemaInfo & info);
|
2019-01-23 19:36:57 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-27 09:15:32 +00:00
|
|
|
class ImporterWithSourceTree;
|
|
|
|
std::unordered_map<String, std::unique_ptr<ImporterWithSourceTree>> importers;
|
2019-01-23 19:36:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2019-01-25 20:02:03 +00:00
|
|
|
|
|
|
|
#endif
|