C++ YT Wrapper
C++ library for working with YT clusters
Loading...
Searching...
No Matches
protobuf_format.h
1#pragma once
2
3#include "common.h"
4
5#include <yt/yt_proto/yt/formats/extension.pb.h>
6
7#include <util/generic/maybe.h>
8
9#include <google/protobuf/message.h>
10
12namespace NYT::NDetail {
13
15
16enum class EProtobufType
17{
18 EnumInt /* "enum_int" */,
19 EnumString /* "enum_string" */,
20 Any /* "any" */,
21 OtherColumns /* "other_columns" */,
22};
23
24enum class EProtobufSerializationMode
25{
26 Protobuf,
27 Yt,
28 Embedded,
29};
30
31enum class EProtobufListMode
32{
33 Optional,
34 Required,
35};
36
37enum class EProtobufMapMode
38{
39 ListOfStructsLegacy,
40 ListOfStructs,
41 Dict,
42 OptionalDict,
43};
44
45enum class EProtobufFieldSortOrder
46{
47 AsInProtoFile,
48 ByFieldNumber,
49};
50
51enum class EProtobufOneofMode
52{
53 SeparateFields,
54 Variant,
55};
56
57enum class EProtobufEnumWritingMode
58{
59 SkipUnknownValues,
60 CheckValues,
61};
62
63struct TProtobufOneofOptions
64{
65 EProtobufOneofMode Mode = EProtobufOneofMode::Variant;
66 TString VariantFieldName;
67};
68
69struct TProtobufFieldOptions
70{
71 TMaybe<EProtobufType> Type;
72 EProtobufSerializationMode SerializationMode = EProtobufSerializationMode::Protobuf;
73 EProtobufListMode ListMode = EProtobufListMode::Required;
74 EProtobufMapMode MapMode = EProtobufMapMode::ListOfStructsLegacy;
75};
76
77struct TProtobufMessageOptions
78{
79 EProtobufFieldSortOrder FieldSortOrder = EProtobufFieldSortOrder::ByFieldNumber;
80};
81
82TString GetColumnName(const ::google::protobuf::FieldDescriptor& field);
83
84TProtobufFieldOptions GetFieldOptions(
85 const ::google::protobuf::FieldDescriptor* fieldDescriptor,
86 const TMaybe<TProtobufFieldOptions>& defaultFieldOptions = {});
87
88TProtobufOneofOptions GetOneofOptions(
89 const ::google::protobuf::OneofDescriptor* oneofDescriptor,
90 const TMaybe<TProtobufOneofOptions>& defaultOneofOptions = {});
91
92TProtobufMessageOptions GetMessageOptions(const ::google::protobuf::Descriptor* descriptor);
93
94TMaybe<TVector<TString>> InferColumnFilter(const ::google::protobuf::Descriptor& descriptor);
95
96TNode MakeProtoFormatConfigWithTables(const TVector<const ::google::protobuf::Descriptor*>& descriptors);
97TNode MakeProtoFormatConfigWithDescriptors(const TVector<const ::google::protobuf::Descriptor*>& descriptors);
98
99TTableSchema CreateTableSchemaImpl(
100 const ::google::protobuf::Descriptor& messageDescriptor,
101 bool keepFieldsWithoutExtension);
102
104
105} // namespace NYT::NDetail