chaoyli closed pull request #510: Be refactor optimize rowset
URL: https://github.com/apache/incubator-doris/pull/510
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/be/src/olap/rowset/alpha_rowset.cpp 
b/be/src/olap/rowset/alpha_rowset.cpp
index cbd69fa0..676533cf 100644
--- a/be/src/olap/rowset/alpha_rowset.cpp
+++ b/be/src/olap/rowset/alpha_rowset.cpp
@@ -52,11 +52,7 @@ OLAPStatus AlphaRowset::init() {
 }
 
 std::unique_ptr<RowsetReader> AlphaRowset::create_reader() {
-    std::vector<SegmentGroup*> segment_groups;
-    for (auto& segment_group : _segment_groups) {
-        segment_groups.push_back(segment_group.get());
-    }
-    return std::unique_ptr<RowsetReader>(new AlphaRowsetReader(_tablet_schema,
+    return std::unique_ptr<RowsetReader>(new AlphaRowsetReader(
             _num_key_fields, _num_short_key_fields, _num_rows_per_row_block,
             _rowset_path, _rowset_meta.get(), _segment_groups));
 }
@@ -72,7 +68,7 @@ OLAPStatus AlphaRowset::remove() {
     return OLAP_SUCCESS;
 }
 
-RowsetMetaSharedPtr AlphaRowset::get_meta() {
+RowsetMetaSharedPtr AlphaRowset::rowset_meta() const {
     return _rowset_meta;
 }
 
@@ -105,14 +101,34 @@ bool 
AlphaRowset::remove_old_files(std::vector<std::string>* removed_links) {
     return true;
 }
 
+int AlphaRowset::data_disk_size() const {
+    return _rowset_meta->total_disk_size();
+}
+
+int AlphaRowset::index_disk_size() const {
+    return _rowset_meta->index_disk_size();
+}
+
+bool AlphaRowset::empty() const {
+    return _rowset_meta->empty();
+}
+
+bool AlphaRowset::zero_num_rows() const {
+    return _rowset_meta->row_number() == 0;
+}
+
+size_t AlphaRowset::num_rows() const {
+    return _rowset_meta->row_number();
+}
+
 OLAPStatus AlphaRowset::_init_segment_groups() {
     std::vector<SegmentGroupPB> segment_group_metas;
     AlphaRowsetMeta* _alpha_rowset_meta = (AlphaRowsetMeta*)_rowset_meta.get();
     _alpha_rowset_meta->get_segment_groups(&segment_group_metas);
     for (auto& segment_group_meta : segment_group_metas) {
         Version version = _rowset_meta->version();
-        int64_t version_hash = _rowset_meta->get_version_hash();
-        std::shared_ptr<SegmentGroup> segment_group(new 
SegmentGroup(_rowset_meta->get_tablet_id(),
+        int64_t version_hash = _rowset_meta->version_hash();
+        std::shared_ptr<SegmentGroup> segment_group(new 
SegmentGroup(_rowset_meta->tablet_id(),
                 _rowset_meta->rowset_id(), _tablet_schema, _num_key_fields, 
_num_short_key_fields,
                 _num_rows_per_row_block, _rowset_path, version, version_hash,
                 false, segment_group_meta.segment_group_id(), 
segment_group_meta.num_segments()));
diff --git a/be/src/olap/rowset/alpha_rowset.h 
b/be/src/olap/rowset/alpha_rowset.h
index 412c4f38..87d4af06 100644
--- a/be/src/olap/rowset/alpha_rowset.h
+++ b/be/src/olap/rowset/alpha_rowset.h
@@ -44,7 +44,7 @@ class AlphaRowset : public Rowset {
 
     virtual OLAPStatus remove();
 
-    virtual RowsetMetaSharedPtr get_meta();
+    virtual RowsetMetaSharedPtr rowset_meta() const;
 
     virtual void set_version(Version version);
 
@@ -52,6 +52,16 @@ class AlphaRowset : public Rowset {
 
     bool remove_old_files(std::vector<std::string>* removed_links);
 
+    virtual int data_disk_size() const;
+
+    virtual int index_disk_size() const;
+
+    virtual bool empty() const;
+
+    virtual bool zero_num_rows() const;
+
+    virtual size_t num_rows() const;
+
 private:
     OLAPStatus _init_segment_groups();
 
diff --git a/be/src/olap/rowset/alpha_rowset_meta.cpp 
b/be/src/olap/rowset/alpha_rowset_meta.cpp
index 1cd12c93..d600d711 100644
--- a/be/src/olap/rowset/alpha_rowset_meta.cpp
+++ b/be/src/olap/rowset/alpha_rowset_meta.cpp
@@ -22,9 +22,8 @@
 namespace doris {
 
 bool AlphaRowsetMeta::deserialize_extra_properties() {
-    std::string extra_properties = get_extra_properties();
-    bool parsed = _extra_meta_pb.ParseFromString(extra_properties);
-    return parsed;
+    std::string properties = extra_properties();
+    return _extra_meta_pb.ParseFromString(properties);
 }
 
 void AlphaRowsetMeta::get_segment_groups(std::vector<SegmentGroupPB>* 
segment_groups) {
diff --git a/be/src/olap/rowset/alpha_rowset_reader.cpp 
b/be/src/olap/rowset/alpha_rowset_reader.cpp
index 67400413..e44ad066 100644
--- a/be/src/olap/rowset/alpha_rowset_reader.cpp
+++ b/be/src/olap/rowset/alpha_rowset_reader.cpp
@@ -19,12 +19,9 @@
 
 namespace doris {
 
-AlphaRowsetReader::AlphaRowsetReader(const RowFields& tablet_schema,
-        int num_key_fields, int num_short_key_fields,
-        int num_rows_per_row_block, const std::string rowset_path,
-        RowsetMeta* rowset_meta,
-        std::vector<std::shared_ptr<SegmentGroup>> segment_groups) : 
_tablet_schema(tablet_schema),
-            _num_key_fields(num_key_fields),
+AlphaRowsetReader::AlphaRowsetReader(int num_key_fields, int 
num_short_key_fields,
+        int num_rows_per_row_block, const std::string rowset_path, RowsetMeta* 
rowset_meta,
+        std::vector<std::shared_ptr<SegmentGroup>> segment_groups) : 
_num_key_fields(num_key_fields),
             _num_short_key_fields(num_short_key_fields),
             _num_rows_per_row_block(num_rows_per_row_block),
             _rowset_path(rowset_path),
diff --git a/be/src/olap/rowset/alpha_rowset_reader.h 
b/be/src/olap/rowset/alpha_rowset_reader.h
index 336b1497..f2f1b4d3 100644
--- a/be/src/olap/rowset/alpha_rowset_reader.h
+++ b/be/src/olap/rowset/alpha_rowset_reader.h
@@ -29,8 +29,7 @@ namespace doris {
 
 class AlphaRowsetReader : public RowsetReader {
 public:
-    AlphaRowsetReader(const RowFields& tablet_schema,
-        int num_key_fields, int num_short_key_fields,
+    AlphaRowsetReader(int num_key_fields, int num_short_key_fields,
         int num_rows_per_row_block, const std::string rowset_path,
         RowsetMeta* rowset_meta, std::vector<std::shared_ptr<SegmentGroup>> 
segment_groups);
 
@@ -60,7 +59,6 @@ class AlphaRowsetReader : public RowsetReader {
     OLAPStatus _refresh_next_block(ColumnData* column_datam, RowBlock* 
row_block);
 
 private:
-    RowFields _tablet_schema;
     int _num_key_fields;
     int _num_short_key_fields;
     int _num_rows_per_row_block;
diff --git a/be/src/olap/rowset/rowset.h b/be/src/olap/rowset/rowset.h
index b2861414..26c55501 100644
--- a/be/src/olap/rowset/rowset.h
+++ b/be/src/olap/rowset/rowset.h
@@ -46,11 +46,18 @@ class Rowset {
     virtual OLAPStatus remove() = 0;
 
     virtual OLAPStatus to_rowset_pb(const RowsetMetaPB& rs_meta);
-    virtual RowsetMetaSharedPtr& get_rs_meta() const;
-    virtual int get_data_disk_size() const;
-    virtual bool empty() const;
-    virtual bool zero_num_rows() const;
-    virtual size_t get_num_rows() const;
+
+    virtual RowsetMetaSharedPtr rowset_meta() const = 0;
+
+    virtual int data_disk_size() const = 0;
+
+    virtual int index_disk_size() const = 0;
+
+    virtual bool empty() const = 0;
+
+    virtual bool zero_num_rows() const = 0;
+
+    virtual size_t num_rows() const = 0;
 };
 
 } // namespace doris
diff --git a/be/src/olap/rowset/rowset_meta.h b/be/src/olap/rowset/rowset_meta.h
index fd4926a4..387e553a 100644
--- a/be/src/olap/rowset/rowset_meta.h
+++ b/be/src/olap/rowset/rowset_meta.h
@@ -60,7 +60,7 @@ class RowsetMeta {
         return _serialize_to_pb(value);
     }
 
-    virtual bool get_json_rowset_meta(std::string* json_rowset_meta) {
+    virtual bool 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);
@@ -75,7 +75,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_rowset_id(rowset_id);
     }
 
-    virtual int64_t get_tablet_id() {
+    virtual int64_t tablet_id() {
         return _rowset_meta_pb.tablet_id();
     }
 
@@ -83,7 +83,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_tablet_id(tablet_id);
     }
 
-    virtual int64_t get_txn_id() {
+    virtual int64_t txn_id() {
         return _rowset_meta_pb.txn_id();
     }
 
@@ -91,7 +91,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_txn_id(txn_id);
     }
 
-    virtual int32_t get_tablet_schema_hash() {
+    virtual int32_t tablet_schema_hash() {
         return _rowset_meta_pb.tablet_schema_hash();
     }
 
@@ -99,7 +99,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_tablet_schema_hash(tablet_schema_hash);
     }
 
-    virtual RowsetTypePB get_rowset_type() {
+    virtual RowsetTypePB rowset_type() {
         return _rowset_meta_pb.rowset_type();
     }
 
@@ -107,7 +107,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_rowset_type(rowset_type);
     }
 
-    virtual RowsetStatePB get_rowset_state() {
+    virtual RowsetStatePB rowset_state() {
         return _rowset_meta_pb.rowset_state();
     }
 
@@ -148,7 +148,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_end_version(end_version);
     }
     
-    virtual int64_t get_version_hash() {
+    virtual int64_t version_hash() {
         return _rowset_meta_pb.version_hash();
     }
 
@@ -156,7 +156,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_version_hash(version_hash);
     }
 
-    virtual int get_row_number() {
+    virtual int row_number() {
         return _rowset_meta_pb.row_number();
     }
 
@@ -164,7 +164,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_row_number(row_number);
     }
 
-    virtual int get_total_disk_size() {
+    virtual int total_disk_size() {
         return _rowset_meta_pb.total_disk_size();
     }
 
@@ -172,7 +172,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_total_disk_size(total_disk_size);
     }
 
-    virtual int get_data_disk_size() {
+    virtual int data_disk_size() {
         return _rowset_meta_pb.data_disk_size();
     }
 
@@ -180,7 +180,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_data_disk_size(data_disk_size);
     }
 
-    virtual int get_index_disk_size() {
+    virtual int index_disk_size() {
         return _rowset_meta_pb.index_disk_size();
     }
 
@@ -188,7 +188,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_index_disk_size(index_disk_size);
     }
 
-    virtual void get_column_statistics(std::vector<ColumnPruning>* 
column_statistics) {
+    virtual void column_statistics(std::vector<ColumnPruning>* 
column_statistics) {
         for (const ColumnPruning& column_statistic : 
_rowset_meta_pb.column_statistics()) {
             column_statistics->push_back(column_statistic);
         }
@@ -206,7 +206,7 @@ class RowsetMeta {
         *new_column_statistic = column_statistic;
     }
 
-    virtual const DeletePredicatePB& get_delete_predicate() {
+    virtual const DeletePredicatePB& delete_predicate() {
         return _rowset_meta_pb.delete_predicate();
     }
 
@@ -215,7 +215,7 @@ class RowsetMeta {
         *new_delete_condition = delete_predicate;
     }
 
-     virtual bool get_empty() {
+     virtual bool empty() {
         return _rowset_meta_pb.empty();
     }
 
@@ -223,7 +223,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_empty(empty);
     }
 
-    virtual std::string get_rowset_path() {
+    virtual std::string rowset_path() {
         return _rowset_meta_pb.rowset_path();
     }
 
@@ -231,7 +231,7 @@ class RowsetMeta {
         _rowset_meta_pb.set_rowset_path(rowset_path);
     }
 
-    virtual PUniqueId get_load_id() {
+    virtual PUniqueId load_id() {
         return _rowset_meta_pb.load_id();
     }
 
@@ -241,11 +241,11 @@ class RowsetMeta {
         new_load_id->set_lo(load_id.lo());
     }
 
-    std::string get_extra_properties() {
+    virtual std::string extra_properties() {
         return _rowset_meta_pb.extra_properties();
     }
 
-    void set_extra_properties(std::string extra_properties) {
+    virtual void set_extra_properties(std::string extra_properties) {
         _rowset_meta_pb.set_extra_properties(extra_properties);
     }
 
diff --git a/be/src/olap/rowset/rowset_meta_manager.cpp 
b/be/src/olap/rowset/rowset_meta_manager.cpp
index 88fd0b64..168559ac 100644
--- a/be/src/olap/rowset/rowset_meta_manager.cpp
+++ b/be/src/olap/rowset/rowset_meta_manager.cpp
@@ -60,7 +60,7 @@ OLAPStatus RowsetMetaManager::get_json_rowset_meta(OlapMeta* 
meta, int64_t rowse
     if (status != OLAP_SUCCESS) {
         return status;
     }
-    bool ret = rowset_meta.get_json_rowset_meta(json_rowset_meta);
+    bool ret = rowset_meta.json_rowset_meta(json_rowset_meta);
     if (!ret) {
         std::string error_msg = "get json rowset meta failed. rowset id:" + 
std::to_string(rowset_id);
         return OLAP_ERR_SERIALIZE_PROTOBUF_ERROR; 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to