Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion be/src/olap/rowset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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 ;
Expand Down
3 changes: 3 additions & 0 deletions be/src/olap/rowset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/schema_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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']",
Expand Down