@@ -104,19 +104,13 @@ class SegmentReaderWriterTest : public ::testing::Test {
104
104
TabletSchemaSPtr create_schema (const std::vector<TabletColumn>& columns,
105
105
KeysType keys_type = DUP_KEYS, int num_custom_key_columns = -1 ) {
106
106
TabletSchemaSPtr res = std::make_shared<TabletSchema>();
107
- int num_key_columns = 0 ;
107
+
108
108
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);
113
110
}
114
- res->_num_columns = columns.size ();
115
- res->_num_key_columns = num_key_columns;
116
111
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 () ;
118
113
res->_keys_type = keys_type;
119
- res->init_field_index_for_test ();
120
114
return res;
121
115
}
122
116
@@ -572,6 +566,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
572
566
std::vector<std::string> vals = {" 2" };
573
567
condition.__set_condition_values (vals);
574
568
std::shared_ptr<Conditions> conditions (new Conditions (tablet_schema));
569
+ condition.__set_column_unique_id (
570
+ tablet_schema->column (condition.column_name ).unique_id ());
575
571
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
576
572
577
573
StorageReadOptions read_opts;
@@ -595,6 +591,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
595
591
std::vector<std::string> vals = {" 100" };
596
592
condition.__set_condition_values (vals);
597
593
std::shared_ptr<Conditions> conditions (new Conditions (tablet_schema));
594
+ condition.__set_column_unique_id (
595
+ tablet_schema->column (condition.column_name ).unique_id ());
598
596
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
599
597
600
598
StorageReadOptions read_opts;
@@ -644,6 +642,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
644
642
std::vector<std::string> vals = {" 165000" };
645
643
condition.__set_condition_values (vals);
646
644
std::shared_ptr<Conditions> conditions (new Conditions (tablet_schema));
645
+ condition.__set_column_unique_id (
646
+ tablet_schema->column (condition.column_name ).unique_id ());
647
647
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
648
648
649
649
// the second page read will be pruned by the following delete predicate
@@ -653,6 +653,8 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
653
653
std::vector<std::string> vals2 = {" 164001" };
654
654
delete_condition.__set_condition_values (vals2);
655
655
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 ());
656
658
EXPECT_EQ (Status::OK (), delete_conditions->append_condition (delete_condition));
657
659
658
660
StorageReadOptions read_opts;
@@ -707,6 +709,10 @@ TEST_F(SegmentReaderWriterTest, TestIndex) {
707
709
std::vector<std::string> vals = {" 102" };
708
710
condition.__set_condition_values (vals);
709
711
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 ());
710
716
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
711
717
read_opts.conditions = conditions.get ();
712
718
std::unique_ptr<RowwiseIterator> iter;
@@ -890,15 +896,12 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
890
896
MemPool pool;
891
897
892
898
std::shared_ptr<TabletSchema> tablet_schema (new TabletSchema ());
893
- tablet_schema->_num_columns = 4 ;
894
- tablet_schema->_num_key_columns = 3 ;
895
899
tablet_schema->_num_short_key_columns = 2 ;
896
900
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 ));
902
905
903
906
SegmentWriterOptions opts;
904
907
opts.num_rows_per_block = num_rows_per_block;
@@ -1057,6 +1060,8 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
1057
1060
std::vector<std::string> vals = {" 100" };
1058
1061
condition.__set_condition_values (vals);
1059
1062
std::shared_ptr<Conditions> conditions (new Conditions (tablet_schema));
1063
+ condition.__set_column_unique_id (
1064
+ tablet_schema->column (condition.column_name ).unique_id ());
1060
1065
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
1061
1066
1062
1067
StorageReadOptions read_opts;
@@ -1114,6 +1119,8 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
1114
1119
std::vector<std::string> vals = {" -2" };
1115
1120
condition.__set_condition_values (vals);
1116
1121
std::shared_ptr<Conditions> conditions (new Conditions (tablet_schema));
1122
+ condition.__set_column_unique_id (
1123
+ tablet_schema->column (condition.column_name ).unique_id ());
1117
1124
EXPECT_EQ (Status::OK (), conditions->append_condition (condition));
1118
1125
1119
1126
StorageReadOptions read_opts;
0 commit comments