github-actions[bot] commented on code in PR #24929:
URL: https://github.com/apache/doris/pull/24929#discussion_r1338187107


##########
be/src/olap/rowset/rowset_meta.cpp:
##########
@@ -0,0 +1,154 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "olap/rowset/rowset_meta.h"
+
+#include "common/logging.h"
+#include "google/protobuf/util/message_differencer.h"
+#include "io/fs/local_file_system.h"
+#include "json2pb/json_to_pb.h"
+#include "json2pb/pb_to_json.h"
+#include "olap/olap_common.h"
+#include "olap/storage_policy.h"
+#include "olap/tablet_schema.h"
+#include "olap/tablet_schema_cache.h"
+
+namespace doris {
+
+RowsetMeta::~RowsetMeta() = default;
+
+bool RowsetMeta::init(const std::string& pb_rowset_meta) {
+    bool ret = _deserialize_from_pb(pb_rowset_meta);
+    if (!ret) {
+        return false;
+    }
+    _init();
+    return true;
+}
+
+bool RowsetMeta::init_from_pb(const RowsetMetaPB& rowset_meta_pb) {
+    if (rowset_meta_pb.has_tablet_schema()) {
+        _schema = TabletSchemaCache::instance()->insert(
+                rowset_meta_pb.tablet_schema().SerializeAsString());
+    }
+    // Release ownership of TabletSchemaPB from `rowset_meta_pb` and then set 
it back to `rowset_meta_pb`,
+    // this won't break const semantics of `rowset_meta_pb`, because 
`rowset_meta_pb` is not changed
+    // before and after call this method.
+    auto& mut_rowset_meta_pb = const_cast<RowsetMetaPB&>(rowset_meta_pb);
+    auto schema = mut_rowset_meta_pb.release_tablet_schema();
+    _rowset_meta_pb = mut_rowset_meta_pb;
+    mut_rowset_meta_pb.set_allocated_tablet_schema(schema);
+    _init();
+    return true;
+}
+
+bool RowsetMeta::init_from_json(const std::string& json_rowset_meta) {
+    bool ret = json2pb::JsonToProtoMessage(json_rowset_meta, &_rowset_meta_pb);
+    if (!ret) {
+        return false;
+    }
+    _init();
+    return true;
+}
+
+bool RowsetMeta::json_rowset_meta(std::string* json_rowset_meta) {
+    json2pb::Pb2JsonOptions json_options;
+    json_options.pretty_json = true;
+    bool ret = json2pb::ProtoMessageToJson(_rowset_meta_pb, json_rowset_meta, 
json_options);
+    return ret;
+}
+
+const io::FileSystemSPtr& RowsetMeta::fs() {

Review Comment:
   warning: method 'fs' can be made const 
[readability-make-member-function-const]
   
   ```suggestion
   const io::FileSystemSPtr& RowsetMeta::fs() const {
   ```
   
   be/src/olap/rowset/rowset_meta.h:48:
   ```diff
   -     const io::FileSystemSPtr& fs();
   +     const io::FileSystemSPtr& fs() const;
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to