Skip to content

Commit bb49fba

Browse files
committed
fix bugs
1 parent 15a59b1 commit bb49fba

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

be/src/olap/tablet_schema.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,6 @@ const TabletColumn& TabletSchema::column(const std::string& field_name) const {
686686
return _cols[found->second];
687687
}
688688

689-
void TabletSchema::init_field_index_for_test() {
690-
_field_name_to_index.clear();
691-
for (int i = 0; i < _cols.size(); ++i) {
692-
_field_name_to_index[_cols[i].name()] = i;
693-
}
694-
}
695-
696689
vectorized::Block TabletSchema::create_block(
697690
const std::vector<uint32_t>& return_columns,
698691
const std::unordered_set<uint32_t>* tablet_columns_need_convert_null) const {

be/src/olap/tablet_schema.h

-3
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ class TabletSchema {
186186
void merge_dropped_columns(std::shared_ptr<TabletSchema> src_schema);
187187

188188
private:
189-
// Only for unit test.
190-
void init_field_index_for_test();
191-
192189
friend bool operator==(const TabletSchema& a, const TabletSchema& b);
193190
friend bool operator!=(const TabletSchema& a, const TabletSchema& b);
194191

be/test/olap/rowset/segment_v2/segment_test.cpp

+23-16
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,13 @@ class SegmentReaderWriterTest : public ::testing::Test {
104104
TabletSchemaSPtr create_schema(const std::vector<TabletColumn>& columns,
105105
KeysType keys_type = DUP_KEYS, int num_custom_key_columns = -1) {
106106
TabletSchemaSPtr res = std::make_shared<TabletSchema>();
107-
int num_key_columns = 0;
107+
108108
for (auto& col : columns) {
109-
if (col.is_key()) {
110-
num_key_columns++;
111-
}
112-
res->_cols.push_back(col);
109+
res->append_column(col);
113110
}
114-
res->_num_columns = columns.size();
115-
res->_num_key_columns = num_key_columns;
116111
res->_num_short_key_columns =
117-
num_custom_key_columns != -1 ? num_custom_key_columns : num_key_columns;
112+
num_custom_key_columns != -1 ? num_custom_key_columns : res->num_key_columns();
118113
res->_keys_type = keys_type;
119-
res->init_field_index_for_test();
120114
return res;
121115
}
122116

@@ -572,6 +566,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
572566
std::vector<std::string> vals = {"2"};
573567
condition.__set_condition_values(vals);
574568
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
569+
condition.__set_column_unique_id(
570+
tablet_schema->column(condition.column_name).unique_id());
575571
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
576572

577573
StorageReadOptions read_opts;
@@ -595,6 +591,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
595591
std::vector<std::string> vals = {"100"};
596592
condition.__set_condition_values(vals);
597593
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
594+
condition.__set_column_unique_id(
595+
tablet_schema->column(condition.column_name).unique_id());
598596
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
599597

600598
StorageReadOptions read_opts;
@@ -644,6 +642,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
644642
std::vector<std::string> vals = {"165000"};
645643
condition.__set_condition_values(vals);
646644
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
645+
condition.__set_column_unique_id(
646+
tablet_schema->column(condition.column_name).unique_id());
647647
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
648648

649649
// the second page read will be pruned by the following delete predicate
@@ -653,6 +653,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
653653
std::vector<std::string> vals2 = {"164001"};
654654
delete_condition.__set_condition_values(vals2);
655655
std::shared_ptr<Conditions> delete_conditions(new Conditions(tablet_schema));
656+
delete_condition.__set_column_unique_id(
657+
tablet_schema->column(delete_condition.column_name).unique_id());
656658
EXPECT_EQ(Status::OK(), delete_conditions->append_condition(delete_condition));
657659

658660
StorageReadOptions read_opts;
@@ -707,6 +709,10 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
707709
std::vector<std::string> vals = {"102"};
708710
condition.__set_condition_values(vals);
709711
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
712+
condition.__set_column_unique_id(
713+
tablet_schema->column(condition.column_name).unique_id());
714+
condition.__set_column_unique_id(
715+
tablet_schema->column(condition.column_name).unique_id());
710716
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
711717
read_opts.conditions = conditions.get();
712718
std::unique_ptr<RowwiseIterator> iter;
@@ -890,15 +896,12 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
890896
MemPool pool;
891897

892898
std::shared_ptr<TabletSchema> tablet_schema(new TabletSchema());
893-
tablet_schema->_num_columns = 4;
894-
tablet_schema->_num_key_columns = 3;
895899
tablet_schema->_num_short_key_columns = 2;
896900
tablet_schema->_num_rows_per_row_block = num_rows_per_block;
897-
tablet_schema->_cols.push_back(create_char_key(1));
898-
tablet_schema->_cols.push_back(create_char_key(2));
899-
tablet_schema->_cols.push_back(create_varchar_key(3));
900-
tablet_schema->_cols.push_back(create_varchar_key(4));
901-
tablet_schema->init_field_index_for_test();
901+
tablet_schema->append_column(create_char_key(1));
902+
tablet_schema->append_column(create_char_key(2));
903+
tablet_schema->append_column(create_varchar_key(3));
904+
tablet_schema->append_column(create_varchar_key(4));
902905

903906
SegmentWriterOptions opts;
904907
opts.num_rows_per_block = num_rows_per_block;
@@ -1057,6 +1060,8 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
10571060
std::vector<std::string> vals = {"100"};
10581061
condition.__set_condition_values(vals);
10591062
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
1063+
condition.__set_column_unique_id(
1064+
tablet_schema->column(condition.column_name).unique_id());
10601065
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
10611066

10621067
StorageReadOptions read_opts;
@@ -1114,6 +1119,8 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
11141119
std::vector<std::string> vals = {"-2"};
11151120
condition.__set_condition_values(vals);
11161121
std::shared_ptr<Conditions> conditions(new Conditions(tablet_schema));
1122+
condition.__set_column_unique_id(
1123+
tablet_schema->column(condition.column_name).unique_id());
11171124
EXPECT_EQ(Status::OK(), conditions->append_condition(condition));
11181125

11191126
StorageReadOptions read_opts;

0 commit comments

Comments
 (0)