From 34766c95b16469ee5f8df3cefdd69b5daa2e6006 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Thu, 9 Jan 2025 13:03:56 +0000 Subject: [PATCH] feat: add `write_hint` to `Mutation` --- c++/greptime/v1/wal.pb.cc | 41 ++++++++-- c++/greptime/v1/wal.pb.h | 31 +++++++ go/greptime/v1/wal.pb.go | 29 +++++-- java/src/main/java/greptime/v1/Wal.java | 104 ++++++++++++++++++++++-- proto/greptime/v1/wal.proto | 2 + 5 files changed, 185 insertions(+), 22 deletions(-) diff --git a/c++/greptime/v1/wal.pb.cc b/c++/greptime/v1/wal.pb.cc index 2a97cffe..d5ef12cb 100644 --- a/c++/greptime/v1/wal.pb.cc +++ b/c++/greptime/v1/wal.pb.cc @@ -26,6 +26,7 @@ PROTOBUF_CONSTEXPR Mutation::Mutation( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.rows_)*/nullptr , /*decltype(_impl_.sequence_)*/uint64_t{0u} + , /*decltype(_impl_.write_hint_)*/uint64_t{0u} , /*decltype(_impl_.op_type_)*/0 , /*decltype(_impl_._cached_size_)*/{}} {} struct MutationDefaultTypeInternal { @@ -66,6 +67,7 @@ const uint32_t TableStruct_greptime_2fv1_2fwal_2eproto::offsets[] PROTOBUF_SECTI PROTOBUF_FIELD_OFFSET(::greptime::v1::Mutation, _impl_.op_type_), PROTOBUF_FIELD_OFFSET(::greptime::v1::Mutation, _impl_.sequence_), PROTOBUF_FIELD_OFFSET(::greptime::v1::Mutation, _impl_.rows_), + PROTOBUF_FIELD_OFFSET(::greptime::v1::Mutation, _impl_.write_hint_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::greptime::v1::WalEntry, _internal_metadata_), ~0u, // no _extensions_ @@ -76,7 +78,7 @@ const uint32_t TableStruct_greptime_2fv1_2fwal_2eproto::offsets[] PROTOBUF_SECTI }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::greptime::v1::Mutation)}, - { 9, -1, -1, sizeof(::greptime::v1::WalEntry)}, + { 10, -1, -1, sizeof(::greptime::v1::WalEntry)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -86,20 +88,21 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_greptime_2fv1_2fwal_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\025greptime/v1/wal.proto\022\013greptime.v1\032\025gr" - "eptime/v1/row.proto\"c\n\010Mutation\022$\n\007op_ty" + "eptime/v1/row.proto\"w\n\010Mutation\022$\n\007op_ty" "pe\030\001 \001(\0162\023.greptime.v1.OpType\022\020\n\010sequenc" "e\030\002 \001(\004\022\037\n\004rows\030\003 \001(\0132\021.greptime.v1.Rows" - "\"4\n\010WalEntry\022(\n\tmutations\030\001 \003(\0132\025.grepti" - "me.v1.Mutation*\035\n\006OpType\022\n\n\006DELETE\020\000\022\007\n\003" - "PUT\020\001B7Z5github.com/GreptimeTeam/greptim" - "e-proto/go/greptime/v1b\006proto3" + "\022\022\n\nwrite_hint\030\004 \001(\004\"4\n\010WalEntry\022(\n\tmuta" + "tions\030\001 \003(\0132\025.greptime.v1.Mutation*\035\n\006Op" + "Type\022\n\n\006DELETE\020\000\022\007\n\003PUT\020\001B7Z5github.com/" + "GreptimeTeam/greptime-proto/go/greptime/" + "v1b\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_greptime_2fv1_2fwal_2eproto_deps[1] = { &::descriptor_table_greptime_2fv1_2frow_2eproto, }; static ::_pbi::once_flag descriptor_table_greptime_2fv1_2fwal_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_greptime_2fv1_2fwal_2eproto = { - false, false, 310, descriptor_table_protodef_greptime_2fv1_2fwal_2eproto, + false, false, 330, descriptor_table_protodef_greptime_2fv1_2fwal_2eproto, "greptime/v1/wal.proto", &descriptor_table_greptime_2fv1_2fwal_2eproto_once, descriptor_table_greptime_2fv1_2fwal_2eproto_deps, 1, 2, schemas, file_default_instances, TableStruct_greptime_2fv1_2fwal_2eproto::offsets, @@ -158,6 +161,7 @@ Mutation::Mutation(const Mutation& from) new (&_impl_) Impl_{ decltype(_impl_.rows_){nullptr} , decltype(_impl_.sequence_){} + , decltype(_impl_.write_hint_){} , decltype(_impl_.op_type_){} , /*decltype(_impl_._cached_size_)*/{}}; @@ -178,6 +182,7 @@ inline void Mutation::SharedCtor( new (&_impl_) Impl_{ decltype(_impl_.rows_){nullptr} , decltype(_impl_.sequence_){uint64_t{0u}} + , decltype(_impl_.write_hint_){uint64_t{0u}} , decltype(_impl_.op_type_){0} , /*decltype(_impl_._cached_size_)*/{} }; @@ -248,6 +253,14 @@ const char* Mutation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; + // uint64 write_hint = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { + _impl_.write_hint_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -297,6 +310,12 @@ uint8_t* Mutation::_InternalSerialize( _Internal::rows(this).GetCachedSize(), target, stream); } + // uint64 write_hint = 4; + if (this->_internal_write_hint() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteUInt64ToArray(4, this->_internal_write_hint(), 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); @@ -325,6 +344,11 @@ size_t Mutation::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_sequence()); } + // uint64 write_hint = 4; + if (this->_internal_write_hint() != 0) { + total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_write_hint()); + } + // .greptime.v1.OpType op_type = 1; if (this->_internal_op_type() != 0) { total_size += 1 + @@ -356,6 +380,9 @@ void Mutation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTO if (from._internal_sequence() != 0) { _this->_internal_set_sequence(from._internal_sequence()); } + if (from._internal_write_hint() != 0) { + _this->_internal_set_write_hint(from._internal_write_hint()); + } if (from._internal_op_type() != 0) { _this->_internal_set_op_type(from._internal_op_type()); } diff --git a/c++/greptime/v1/wal.pb.h b/c++/greptime/v1/wal.pb.h index 302a0859..d941325a 100644 --- a/c++/greptime/v1/wal.pb.h +++ b/c++/greptime/v1/wal.pb.h @@ -213,6 +213,7 @@ class Mutation final : enum : int { kRowsFieldNumber = 3, kSequenceFieldNumber = 2, + kWriteHintFieldNumber = 4, kOpTypeFieldNumber = 1, }; // .greptime.v1.Rows rows = 3; @@ -242,6 +243,15 @@ class Mutation final : void _internal_set_sequence(uint64_t value); public: + // uint64 write_hint = 4; + void clear_write_hint(); + uint64_t write_hint() const; + void set_write_hint(uint64_t value); + private: + uint64_t _internal_write_hint() const; + void _internal_set_write_hint(uint64_t value); + public: + // .greptime.v1.OpType op_type = 1; void clear_op_type(); ::greptime::v1::OpType op_type() const; @@ -261,6 +271,7 @@ class Mutation final : struct Impl_ { ::greptime::v1::Rows* rows_; uint64_t sequence_; + uint64_t write_hint_; int op_type_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; @@ -560,6 +571,26 @@ inline void Mutation::set_allocated_rows(::greptime::v1::Rows* rows) { // @@protoc_insertion_point(field_set_allocated:greptime.v1.Mutation.rows) } +// uint64 write_hint = 4; +inline void Mutation::clear_write_hint() { + _impl_.write_hint_ = uint64_t{0u}; +} +inline uint64_t Mutation::_internal_write_hint() const { + return _impl_.write_hint_; +} +inline uint64_t Mutation::write_hint() const { + // @@protoc_insertion_point(field_get:greptime.v1.Mutation.write_hint) + return _internal_write_hint(); +} +inline void Mutation::_internal_set_write_hint(uint64_t value) { + + _impl_.write_hint_ = value; +} +inline void Mutation::set_write_hint(uint64_t value) { + _internal_set_write_hint(value); + // @@protoc_insertion_point(field_set:greptime.v1.Mutation.write_hint) +} + // ------------------------------------------------------------------- // WalEntry diff --git a/go/greptime/v1/wal.pb.go b/go/greptime/v1/wal.pb.go index 4243c8bb..beef10c1 100644 --- a/go/greptime/v1/wal.pb.go +++ b/go/greptime/v1/wal.pb.go @@ -95,6 +95,8 @@ type Mutation struct { Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` // Row updates to write to the WAL. Rows *Rows `protobuf:"bytes,3,opt,name=rows,proto3" json:"rows,omitempty"` + // Write hint of the mutation. + WriteHint uint64 `protobuf:"varint,4,opt,name=write_hint,json=writeHint,proto3" json:"write_hint,omitempty"` } func (x *Mutation) Reset() { @@ -150,6 +152,13 @@ func (x *Mutation) GetRows() *Rows { return nil } +func (x *Mutation) GetWriteHint() uint64 { + if x != nil { + return x.WriteHint + } + return 0 +} + // A WAL entry contains a list of mutations for a region to write. type WalEntry struct { state protoimpl.MessageState @@ -205,15 +214,17 @@ var file_greptime_v1_wal_proto_rawDesc = []byte{ 0x0a, 0x15, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x77, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x15, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, - 0x31, 0x2f, 0x72, 0x6f, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7b, 0x0a, 0x08, 0x4d, - 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x07, 0x6f, 0x70, 0x5f, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, - 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, 0x6f, - 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x11, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f, - 0x77, 0x73, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x3f, 0x0a, 0x08, 0x57, 0x61, 0x6c, 0x45, + 0x31, 0x2f, 0x72, 0x6f, 0x77, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9a, 0x01, 0x0a, 0x08, + 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x07, 0x6f, 0x70, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x65, 0x70, + 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, + 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x11, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x6f, 0x77, 0x73, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x77, 0x72, 0x69, + 0x74, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x77, + 0x72, 0x69, 0x74, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x3f, 0x0a, 0x08, 0x57, 0x61, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x33, 0x0a, 0x09, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x72, 0x65, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, diff --git a/java/src/main/java/greptime/v1/Wal.java b/java/src/main/java/greptime/v1/Wal.java index 1ec61be6..9014c5fe 100644 --- a/java/src/main/java/greptime/v1/Wal.java +++ b/java/src/main/java/greptime/v1/Wal.java @@ -201,6 +201,16 @@ public interface MutationOrBuilder extends * .greptime.v1.Rows rows = 3; */ io.greptime.v1.RowData.RowsOrBuilder getRowsOrBuilder(); + + /** + *
+     * Write hint of the mutation.
+     * 
+ * + * uint64 write_hint = 4; + * @return The writeHint. + */ + long getWriteHint(); } /** *
@@ -276,6 +286,11 @@ private Mutation(
 
               break;
             }
+            case 32: {
+
+              writeHint_ = input.readUInt64();
+              break;
+            }
             default: {
               if (!parseUnknownField(
                   input, unknownFields, extensionRegistry, tag)) {
@@ -390,6 +405,21 @@ public io.greptime.v1.RowData.RowsOrBuilder getRowsOrBuilder() {
       return getRows();
     }
 
+    public static final int WRITE_HINT_FIELD_NUMBER = 4;
+    private long writeHint_;
+    /**
+     * 
+     * Write hint of the mutation.
+     * 
+ * + * uint64 write_hint = 4; + * @return The writeHint. + */ + @java.lang.Override + public long getWriteHint() { + return writeHint_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -413,6 +443,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (rows_ != null) { output.writeMessage(3, getRows()); } + if (writeHint_ != 0L) { + output.writeUInt64(4, writeHint_); + } unknownFields.writeTo(output); } @@ -434,6 +467,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, getRows()); } + if (writeHint_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(4, writeHint_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -457,6 +494,8 @@ public boolean equals(final java.lang.Object obj) { if (!getRows() .equals(other.getRows())) return false; } + if (getWriteHint() + != other.getWriteHint()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -477,6 +516,9 @@ public int hashCode() { hash = (37 * hash) + ROWS_FIELD_NUMBER; hash = (53 * hash) + getRows().hashCode(); } + hash = (37 * hash) + WRITE_HINT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getWriteHint()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -624,6 +666,8 @@ public Builder clear() { rows_ = null; rowsBuilder_ = null; } + writeHint_ = 0L; + return this; } @@ -657,6 +701,7 @@ public greptime.v1.Wal.Mutation buildPartial() { } else { result.rows_ = rowsBuilder_.build(); } + result.writeHint_ = writeHint_; onBuilt(); return result; } @@ -714,6 +759,9 @@ public Builder mergeFrom(greptime.v1.Wal.Mutation other) { if (other.hasRows()) { mergeRows(other.getRows()); } + if (other.getWriteHint() != 0L) { + setWriteHint(other.getWriteHint()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1014,6 +1062,49 @@ public io.greptime.v1.RowData.RowsOrBuilder getRowsOrBuilder() { } return rowsBuilder_; } + + private long writeHint_ ; + /** + *
+       * Write hint of the mutation.
+       * 
+ * + * uint64 write_hint = 4; + * @return The writeHint. + */ + @java.lang.Override + public long getWriteHint() { + return writeHint_; + } + /** + *
+       * Write hint of the mutation.
+       * 
+ * + * uint64 write_hint = 4; + * @param value The writeHint to set. + * @return This builder for chaining. + */ + public Builder setWriteHint(long value) { + + writeHint_ = value; + onChanged(); + return this; + } + /** + *
+       * Write hint of the mutation.
+       * 
+ * + * uint64 write_hint = 4; + * @return This builder for chaining. + */ + public Builder clearWriteHint() { + + writeHint_ = 0L; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -2002,13 +2093,14 @@ public greptime.v1.Wal.WalEntry getDefaultInstanceForType() { static { java.lang.String[] descriptorData = { "\n\025greptime/v1/wal.proto\022\013greptime.v1\032\025gr" + - "eptime/v1/row.proto\"c\n\010Mutation\022$\n\007op_ty" + + "eptime/v1/row.proto\"w\n\010Mutation\022$\n\007op_ty" + "pe\030\001 \001(\0162\023.greptime.v1.OpType\022\020\n\010sequenc" + "e\030\002 \001(\004\022\037\n\004rows\030\003 \001(\0132\021.greptime.v1.Rows" + - "\"4\n\010WalEntry\022(\n\tmutations\030\001 \003(\0132\025.grepti" + - "me.v1.Mutation*\035\n\006OpType\022\n\n\006DELETE\020\000\022\007\n\003" + - "PUT\020\001B7Z5github.com/GreptimeTeam/greptim" + - "e-proto/go/greptime/v1b\006proto3" + "\022\022\n\nwrite_hint\030\004 \001(\004\"4\n\010WalEntry\022(\n\tmuta" + + "tions\030\001 \003(\0132\025.greptime.v1.Mutation*\035\n\006Op" + + "Type\022\n\n\006DELETE\020\000\022\007\n\003PUT\020\001B7Z5github.com/" + + "GreptimeTeam/greptime-proto/go/greptime/" + + "v1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -2020,7 +2112,7 @@ public greptime.v1.Wal.WalEntry getDefaultInstanceForType() { internal_static_greptime_v1_Mutation_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_greptime_v1_Mutation_descriptor, - new java.lang.String[] { "OpType", "Sequence", "Rows", }); + new java.lang.String[] { "OpType", "Sequence", "Rows", "WriteHint", }); internal_static_greptime_v1_WalEntry_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_greptime_v1_WalEntry_fieldAccessorTable = new diff --git a/proto/greptime/v1/wal.proto b/proto/greptime/v1/wal.proto index 1ca9d39c..7698c583 100644 --- a/proto/greptime/v1/wal.proto +++ b/proto/greptime/v1/wal.proto @@ -36,6 +36,8 @@ message Mutation { uint64 sequence = 2; // Row updates to write to the WAL. Rows rows = 3; + // Write hint of the mutation. + uint64 write_hint = 4; } // A WAL entry contains a list of mutations for a region to write.