chaoyli commented on a change in pull request #1200: Merge refactor code into 
master
URL: https://github.com/apache/incubator-doris/pull/1200#discussion_r288380282
 
 

 ##########
 File path: be/src/olap/olap_snapshot_converter.cpp
 ##########
 @@ -0,0 +1,531 @@
+// 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/olap_snapshot_converter.h"
+
+#include "olap/rowset/alpha_rowset.h"
+#include "olap/rowset/rowset_id_generator.h"
+
+namespace doris {
+
+OLAPStatus OlapSnapshotConverter::to_olap_header(const TabletMetaPB& 
tablet_meta_pb, OLAPHeaderMessage* olap_header) {
+    if (!tablet_meta_pb.schema().has_num_rows_per_row_block()) {
+        LOG(FATAL) << "tablet schema does not have num_rows_per_row_block."
+                   << " tablet id = " << tablet_meta_pb.tablet_id();
+    }
+    
olap_header->set_num_rows_per_data_block(tablet_meta_pb.schema().num_rows_per_row_block());
+    if (!tablet_meta_pb.has_cumulative_layer_point()) {
+        LOG(FATAL) << "tablet schema does not have cumulative_layer_point."
+                   << " tablet id = " << tablet_meta_pb.tablet_id();
+    }
+    
olap_header->set_cumulative_layer_point(tablet_meta_pb.cumulative_layer_point());
+    if (!tablet_meta_pb.schema().has_num_short_key_columns()) {
+        LOG(FATAL) << "tablet schema does not have num_short_key_columns."
+                   << " tablet id = " << tablet_meta_pb.tablet_id();
+    }
+    
olap_header->set_num_short_key_fields(tablet_meta_pb.schema().num_short_key_columns());
+
+    for (auto& column : tablet_meta_pb.schema().column()) {
+        ColumnMessage* column_msg = olap_header->add_column();
+        to_column_msg(column, column_msg);
+    }
+
+    if (!tablet_meta_pb.has_creation_time()) {
+        LOG(FATAL) << "tablet schema does not have creation_time."
+                   << " tablet id = " << tablet_meta_pb.tablet_id();
+    }
+    olap_header->set_creation_time(tablet_meta_pb.creation_time());
+    olap_header->set_data_file_type(DataFileType::COLUMN_ORIENTED_FILE);
+    if (tablet_meta_pb.schema().has_next_column_unique_id()) {
+        
olap_header->set_next_column_unique_id(tablet_meta_pb.schema().next_column_unique_id());
+    }
+    if (tablet_meta_pb.schema().has_compress_kind()) {
+        
olap_header->set_compress_kind(tablet_meta_pb.schema().compress_kind());
+    }
+    if (tablet_meta_pb.schema().has_bf_fpp()) {
+        olap_header->set_bf_fpp(tablet_meta_pb.schema().bf_fpp());
+    }
+    if (tablet_meta_pb.schema().has_keys_type()) {
+        olap_header->set_keys_type(tablet_meta_pb.schema().keys_type());
+    }
+
+    for (auto& rs_meta : tablet_meta_pb.rs_metas()) {
+        PDelta* pdelta = olap_header->add_delta();
+        convert_to_pdelta(rs_meta, pdelta);
+    }
+    // not add pending delta, it is usedless in clone or backup restore
+    for (auto& inc_rs_meta : tablet_meta_pb.inc_rs_metas()) {
+        PDelta* pdelta = olap_header->add_incremental_delta();
+        convert_to_pdelta(inc_rs_meta, pdelta);
+    }
+    if (tablet_meta_pb.has_in_restore_mode()) {
+        olap_header->set_in_restore_mode(tablet_meta_pb.in_restore_mode());
+    }
+    if (tablet_meta_pb.has_tablet_id()) {
+        olap_header->set_tablet_id(tablet_meta_pb.tablet_id());
+    }
+    if (tablet_meta_pb.has_schema_hash()) {
+        olap_header->set_schema_hash(tablet_meta_pb.schema_hash());
+    }
+    if (tablet_meta_pb.has_shard_id()) {
+        olap_header->set_shard(tablet_meta_pb.shard_id());
+    }
+    return OLAP_SUCCESS;
+}
+
+OLAPStatus OlapSnapshotConverter::to_tablet_meta_pb(const OLAPHeaderMessage& 
olap_header,
+        TabletMetaPB* tablet_meta_pb, vector<RowsetMetaPB>* pending_rowsets) {
+    if (olap_header.has_tablet_id()) {
 
 Review comment:
   no table_id and partition_id.
   If convert to success, following operation can not get partition_id from 
tablet.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to