ClickHouse/src/Formats/ProtobufSerializer.h
Vitaly Baranov 18e036d19b Improved serialization for data types combined of Arrays and Tuples.
Improved matching enum data types to protobuf enum type.
Fixed serialization of the Map data type.
Omitted values are now set by default.
2021-02-17 20:50:09 +03:00

53 lines
1.4 KiB
C++

#pragma once
#if !defined(ARCADIA_BUILD)
# include "config_formats.h"
#endif
#if USE_PROTOBUF
# include <Columns/IColumn.h>
namespace google::protobuf { class Descriptor; }
namespace DB
{
class ProtobufReader;
class ProtobufWriter;
class IDataType;
using DataTypePtr = std::shared_ptr<const IDataType>;
using DataTypes = std::vector<DataTypePtr>;
/// Utility class, does all the work for serialization in the Protobuf format.
class ProtobufSerializer
{
public:
virtual ~ProtobufSerializer() = default;
virtual void setColumns(const ColumnPtr * columns, size_t num_columns) = 0;
virtual void writeRow(size_t row_num) = 0;
virtual void setColumns(const MutableColumnPtr * columns, size_t num_columns) = 0;
virtual void readRow(size_t row_num) = 0;
virtual void insertDefaults(size_t row_num) = 0;
static std::unique_ptr<ProtobufSerializer> create(
const Strings & column_names,
const DataTypes & data_types,
std::vector<size_t> & missing_column_indices,
const google::protobuf::Descriptor & message_descriptor,
bool with_length_delimiter,
ProtobufReader & reader);
static std::unique_ptr<ProtobufSerializer> create(
const Strings & column_names,
const DataTypes & data_types,
const google::protobuf::Descriptor & message_descriptor,
bool with_length_delimiter,
ProtobufWriter & writer);
};
}
#endif