You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2018/11/22 07:39:03 UTC

[GitHub] morningman closed pull request #337: Fix add Rollup bug

morningman closed pull request #337: Fix add Rollup bug
URL: https://github.com/apache/incubator-doris/pull/337
 
 
   

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.cpp b/be/src/olap/rowset.cpp
index 5b9074ed..240afd66 100644
--- a/be/src/olap/rowset.cpp
+++ b/be/src/olap/rowset.cpp
@@ -198,6 +198,30 @@ void Rowset::delete_all_files() {
     }
 }
 
+OLAPStatus Rowset::add_column_statistics_for_linked_schema_change(
+        const std::vector<std::pair<WrapperField*, WrapperField*>>& column_statistic_fields) {
+    //When add rollup table, the base table index maybe empty
+    if (column_statistic_fields.size() == 0) {
+        return OLAP_SUCCESS;
+    }
+
+    //Should use _table->num_key_fields(), not column_statistic_fields.size()
+    //as rollup table num_key_fields will less than base table column_statistic_fields.size().
+    //For LinkedSchemaChange, the rollup table keys order is the same as base table
+    for (size_t i = 0; i < _table->num_key_fields(); ++i) {
+        WrapperField* first = WrapperField::create(_table->tablet_schema()[i]);
+        DCHECK(first != NULL) << "failed to allocate memory for field: " << i;
+        first->copy(column_statistic_fields[i].first);
+
+        WrapperField* second = WrapperField::create(_table->tablet_schema()[i]);
+        DCHECK(second != NULL) << "failed to allocate memory for field: " << i;
+        second->copy(column_statistic_fields[i].second);
+
+        _column_statistics.push_back(std::make_pair(first, second));
+    }
+    return OLAP_SUCCESS;
+}
+
 OLAPStatus Rowset::add_column_statistics(
         const std::vector<std::pair<WrapperField*, WrapperField*>>& column_statistic_fields) {
     DCHECK(column_statistic_fields.size() == _table->num_key_fields());
@@ -219,7 +243,6 @@ OLAPStatus Rowset::add_column_statistics(
         std::vector<std::pair<std::string, std::string> > &column_statistic_strings,
         std::vector<bool> &null_vec) {
     DCHECK(column_statistic_strings.size() == _table->num_key_fields());
-    std::vector<std::pair<WrapperField*, WrapperField*>> column_statistics;
     for (size_t i = 0; i < column_statistic_strings.size(); ++i) {
         WrapperField* first = WrapperField::create(_table->tablet_schema()[i]);
         DCHECK(first != NULL) << "failed to allocate memory for field: " << i ;
diff --git a/be/src/olap/rowset.h b/be/src/olap/rowset.h
index 9c8b82ce..59d5450a 100644
--- a/be/src/olap/rowset.h
+++ b/be/src/olap/rowset.h
@@ -65,6 +65,9 @@ class Rowset {
         return _column_statistics.size() != 0;
     }
 
+    OLAPStatus add_column_statistics_for_linked_schema_change(
+        const std::vector<std::pair<WrapperField*, WrapperField*>>& column_statistic_fields);
+
     OLAPStatus add_column_statistics(
         const std::vector<std::pair<WrapperField*, WrapperField*>>& column_statistic_fields);
 
diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index f771f657..54d35170 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -715,7 +715,7 @@ bool LinkedSchemaChange::process(ColumnData* olap_data, Rowset* new_rowset) {
 
     new_rowset->set_empty(olap_data->empty());
     new_rowset->set_num_segments(olap_data->olap_index()->num_segments());
-    new_rowset->add_column_statistics(olap_data->olap_index()->get_column_statistics());
+    new_rowset->add_column_statistics_for_linked_schema_change(olap_data->olap_index()->get_column_statistics());
 
     if (OLAP_SUCCESS != new_rowset->load()) {
         OLAP_LOG_WARNING("fail to reload index. [table='%s' version='%d-%d']",


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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