feat: add comment field to ColumnDef (#104)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2023-09-17 05:59:41 -05:00
committed by GitHub
parent e81a60e817
commit 637c54338f
5 changed files with 316 additions and 38 deletions
+62 -10
View File
@@ -228,6 +228,7 @@ PROTOBUF_CONSTEXPR ColumnDef::ColumnDef(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
, /*decltype(_impl_.default_constraint_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
, /*decltype(_impl_.comment_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
, /*decltype(_impl_.data_type_)*/0
, /*decltype(_impl_.is_nullable_)*/false
, /*decltype(_impl_.semantic_type_)*/0
@@ -407,6 +408,7 @@ const uint32_t TableStruct_greptime_2fv1_2fddl_2eproto::offsets[] PROTOBUF_SECTI
PROTOBUF_FIELD_OFFSET(::greptime::v1::ColumnDef, _impl_.is_nullable_),
PROTOBUF_FIELD_OFFSET(::greptime::v1::ColumnDef, _impl_.default_constraint_),
PROTOBUF_FIELD_OFFSET(::greptime::v1::ColumnDef, _impl_.semantic_type_),
PROTOBUF_FIELD_OFFSET(::greptime::v1::ColumnDef, _impl_.comment_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::greptime::v1::AddColumnLocation, _internal_metadata_),
~0u, // no _extensions_
@@ -432,7 +434,7 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode
{ 120, -1, -1, sizeof(::greptime::v1::DropColumn)},
{ 127, -1, -1, sizeof(::greptime::v1::TableId)},
{ 134, -1, -1, sizeof(::greptime::v1::ColumnDef)},
{ 145, -1, -1, sizeof(::greptime::v1::AddColumnLocation)},
{ 146, -1, -1, sizeof(::greptime::v1::AddColumnLocation)},
};
static const ::_pb::Message* const file_default_instances[] = {
@@ -498,24 +500,24 @@ const char descriptor_table_protodef_greptime_2fv1_2fddl_2eproto[] PROTOBUF_SECT
"\026.greptime.v1.ColumnDef\0220\n\010location\030\003 \001("
"\0132\036.greptime.v1.AddColumnLocation\"\032\n\nDro"
"pColumn\022\014\n\004name\030\001 \001(\t\"\025\n\007TableId\022\n\n\002id\030\001"
" \001(\r\"\254\001\n\tColumnDef\022\014\n\004name\030\001 \001(\t\022.\n\tdata"
" \001(\r\"\275\001\n\tColumnDef\022\014\n\004name\030\001 \001(\t\022.\n\tdata"
"_type\030\002 \001(\0162\033.greptime.v1.ColumnDataType"
"\022\023\n\013is_nullable\030\003 \001(\010\022\032\n\022default_constra"
"int\030\004 \001(\014\0220\n\rsemantic_type\030\005 \001(\0162\031.grept"
"ime.v1.SemanticType\"\230\001\n\021AddColumnLocatio"
"n\022B\n\rlocation_type\030\001 \001(\0162+.greptime.v1.A"
"ddColumnLocation.LocationType\022\031\n\021after_c"
"olumn_name\030\002 \001(\t\"$\n\014LocationType\022\t\n\005FIRS"
"T\020\000\022\t\n\005AFTER\020\001BL\n\016io.greptime.v1B\003DdlZ5g"
"ithub.com/GreptimeTeam/greptime-proto/go"
"/greptime/v1b\006proto3"
"ime.v1.SemanticType\022\017\n\007comment\030\006 \001(\t\"\230\001\n"
"\021AddColumnLocation\022B\n\rlocation_type\030\001 \001("
"\0162+.greptime.v1.AddColumnLocation.Locati"
"onType\022\031\n\021after_column_name\030\002 \001(\t\"$\n\014Loc"
"ationType\022\t\n\005FIRST\020\000\022\t\n\005AFTER\020\001BL\n\016io.gr"
"eptime.v1B\003DdlZ5github.com/GreptimeTeam/"
"greptime-proto/go/greptime/v1b\006proto3"
;
static const ::_pbi::DescriptorTable* const descriptor_table_greptime_2fv1_2fddl_2eproto_deps[1] = {
&::descriptor_table_greptime_2fv1_2fcommon_2eproto,
};
static ::_pbi::once_flag descriptor_table_greptime_2fv1_2fddl_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_greptime_2fv1_2fddl_2eproto = {
false, false, 2140, descriptor_table_protodef_greptime_2fv1_2fddl_2eproto,
false, false, 2157, descriptor_table_protodef_greptime_2fv1_2fddl_2eproto,
"greptime/v1/ddl.proto",
&descriptor_table_greptime_2fv1_2fddl_2eproto_once, descriptor_table_greptime_2fv1_2fddl_2eproto_deps, 1, 16,
schemas, file_default_instances, TableStruct_greptime_2fv1_2fddl_2eproto::offsets,
@@ -4440,6 +4442,7 @@ ColumnDef::ColumnDef(const ColumnDef& from)
new (&_impl_) Impl_{
decltype(_impl_.name_){}
, decltype(_impl_.default_constraint_){}
, decltype(_impl_.comment_){}
, decltype(_impl_.data_type_){}
, decltype(_impl_.is_nullable_){}
, decltype(_impl_.semantic_type_){}
@@ -4462,6 +4465,14 @@ ColumnDef::ColumnDef(const ColumnDef& from)
_this->_impl_.default_constraint_.Set(from._internal_default_constraint(),
_this->GetArenaForAllocation());
}
_impl_.comment_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.comment_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (!from._internal_comment().empty()) {
_this->_impl_.comment_.Set(from._internal_comment(),
_this->GetArenaForAllocation());
}
::memcpy(&_impl_.data_type_, &from._impl_.data_type_,
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.semantic_type_) -
reinterpret_cast<char*>(&_impl_.data_type_)) + sizeof(_impl_.semantic_type_));
@@ -4475,6 +4486,7 @@ inline void ColumnDef::SharedCtor(
new (&_impl_) Impl_{
decltype(_impl_.name_){}
, decltype(_impl_.default_constraint_){}
, decltype(_impl_.comment_){}
, decltype(_impl_.data_type_){0}
, decltype(_impl_.is_nullable_){false}
, decltype(_impl_.semantic_type_){0}
@@ -4488,6 +4500,10 @@ inline void ColumnDef::SharedCtor(
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.default_constraint_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.comment_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.comment_.Set("", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
ColumnDef::~ColumnDef() {
@@ -4503,6 +4519,7 @@ inline void ColumnDef::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
_impl_.name_.Destroy();
_impl_.default_constraint_.Destroy();
_impl_.comment_.Destroy();
}
void ColumnDef::SetCachedSize(int size) const {
@@ -4517,6 +4534,7 @@ void ColumnDef::Clear() {
_impl_.name_.ClearToEmpty();
_impl_.default_constraint_.ClearToEmpty();
_impl_.comment_.ClearToEmpty();
::memset(&_impl_.data_type_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&_impl_.semantic_type_) -
reinterpret_cast<char*>(&_impl_.data_type_)) + sizeof(_impl_.semantic_type_));
@@ -4574,6 +4592,16 @@ const char* ColumnDef::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx
} else
goto handle_unusual;
continue;
// string comment = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
auto str = _internal_mutable_comment();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "greptime.v1.ColumnDef.comment"));
} else
goto handle_unusual;
continue;
default:
goto handle_unusual;
} // switch
@@ -4639,6 +4667,16 @@ uint8_t* ColumnDef::_InternalSerialize(
5, this->_internal_semantic_type(), target);
}
// string comment = 6;
if (!this->_internal_comment().empty()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_comment().data(), static_cast<int>(this->_internal_comment().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"greptime.v1.ColumnDef.comment");
target = stream->WriteStringMaybeAliased(
6, this->_internal_comment(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
@@ -4669,6 +4707,13 @@ size_t ColumnDef::ByteSizeLong() const {
this->_internal_default_constraint());
}
// string comment = 6;
if (!this->_internal_comment().empty()) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_comment());
}
// .greptime.v1.ColumnDataType data_type = 2;
if (this->_internal_data_type() != 0) {
total_size += 1 +
@@ -4710,6 +4755,9 @@ void ColumnDef::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT
if (!from._internal_default_constraint().empty()) {
_this->_internal_set_default_constraint(from._internal_default_constraint());
}
if (!from._internal_comment().empty()) {
_this->_internal_set_comment(from._internal_comment());
}
if (from._internal_data_type() != 0) {
_this->_internal_set_data_type(from._internal_data_type());
}
@@ -4746,6 +4794,10 @@ void ColumnDef::InternalSwap(ColumnDef* other) {
&_impl_.default_constraint_, lhs_arena,
&other->_impl_.default_constraint_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&_impl_.comment_, lhs_arena,
&other->_impl_.comment_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::memswap<
PROTOBUF_FIELD_OFFSET(ColumnDef, _impl_.semantic_type_)
+ sizeof(ColumnDef::_impl_.semantic_type_)
+66
View File
@@ -2737,6 +2737,7 @@ class ColumnDef final :
enum : int {
kNameFieldNumber = 1,
kDefaultConstraintFieldNumber = 4,
kCommentFieldNumber = 6,
kDataTypeFieldNumber = 2,
kIsNullableFieldNumber = 3,
kSemanticTypeFieldNumber = 5,
@@ -2769,6 +2770,20 @@ class ColumnDef final :
std::string* _internal_mutable_default_constraint();
public:
// string comment = 6;
void clear_comment();
const std::string& comment() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_comment(ArgT0&& arg0, ArgT... args);
std::string* mutable_comment();
PROTOBUF_NODISCARD std::string* release_comment();
void set_allocated_comment(std::string* comment);
private:
const std::string& _internal_comment() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_comment(const std::string& value);
std::string* _internal_mutable_comment();
public:
// .greptime.v1.ColumnDataType data_type = 2;
void clear_data_type();
::greptime::v1::ColumnDataType data_type() const;
@@ -2806,6 +2821,7 @@ class ColumnDef final :
struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr name_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr default_constraint_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr comment_;
int data_type_;
bool is_nullable_;
int semantic_type_;
@@ -5504,6 +5520,56 @@ inline void ColumnDef::set_semantic_type(::greptime::v1::SemanticType value) {
// @@protoc_insertion_point(field_set:greptime.v1.ColumnDef.semantic_type)
}
// string comment = 6;
inline void ColumnDef::clear_comment() {
_impl_.comment_.ClearToEmpty();
}
inline const std::string& ColumnDef::comment() const {
// @@protoc_insertion_point(field_get:greptime.v1.ColumnDef.comment)
return _internal_comment();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void ColumnDef::set_comment(ArgT0&& arg0, ArgT... args) {
_impl_.comment_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:greptime.v1.ColumnDef.comment)
}
inline std::string* ColumnDef::mutable_comment() {
std::string* _s = _internal_mutable_comment();
// @@protoc_insertion_point(field_mutable:greptime.v1.ColumnDef.comment)
return _s;
}
inline const std::string& ColumnDef::_internal_comment() const {
return _impl_.comment_.Get();
}
inline void ColumnDef::_internal_set_comment(const std::string& value) {
_impl_.comment_.Set(value, GetArenaForAllocation());
}
inline std::string* ColumnDef::_internal_mutable_comment() {
return _impl_.comment_.Mutable(GetArenaForAllocation());
}
inline std::string* ColumnDef::release_comment() {
// @@protoc_insertion_point(field_release:greptime.v1.ColumnDef.comment)
return _impl_.comment_.Release();
}
inline void ColumnDef::set_allocated_comment(std::string* comment) {
if (comment != nullptr) {
} else {
}
_impl_.comment_.SetAllocated(comment, GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.comment_.IsDefault()) {
_impl_.comment_.Set("", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:greptime.v1.ColumnDef.comment)
}
// -------------------------------------------------------------------
// AddColumnLocation