@@ -1186,6 +1186,41 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extrac
11861186 _storage_page_size = schema.storage_page_size ();
11871187 _storage_dict_page_size = schema.storage_dict_page_size ();
11881188 _schema_version = schema.schema_version ();
1189+ auto column_groups_pb = schema.seq_map ();
1190+ _seq_map.clear ();
1191+ _value_to_seq.clear ();
1192+ /*
1193+ * ColumnGroupsPB is a list of cg_pb, and
1194+ * ColumnGroupsPB do not have begin() or end() method.
1195+ * we must use for(i=0;i<xx;i++) loop
1196+ */
1197+ for (int i = 0 ; i < column_groups_pb.cg_size (); i++) {
1198+ ColumnGroupPB cg_pb = column_groups_pb.cg (i);
1199+ uint32_t key = cg_pb.sequence_column ();
1200+ for (auto j : cg_pb.columns_in_group ()) {
1201+ _seq_map[key].push_back (j);
1202+ }
1203+ }
1204+
1205+ if (_seq_map.size () > 0 ) {
1206+ /*
1207+ |** KEY **| ** VALUE ** |
1208+ ------------------------------------
1209+ |** KEY **| CDE is value| sequence|
1210+ |----|----|----|----|----|----|----|
1211+ A B C D E S1 S2
1212+ 0 1 2 3 4 5 6
1213+ for example: _seq_map is {5:{2,3}, 6:{4}}
1214+ then, _value_to_seq = {2:5,3:5,5:5,4:6,6:6}
1215+ */
1216+ for (auto it = _seq_map.cbegin (); it != _seq_map.cend (); it++) {
1217+ auto k = it->first ;
1218+ for (auto v : it->second ) {
1219+ _value_to_seq[v] = k;
1220+ }
1221+ _value_to_seq[k] = k;
1222+ }
1223+ }
11891224 // Default to V1 inverted index storage format for backward compatibility if not specified in schema.
11901225 if (!schema.has_inverted_index_storage_format ()) {
11911226 _inverted_index_storage_format = InvertedIndexStorageFormatPB::V1;
@@ -1449,6 +1484,15 @@ void TabletSchema::to_schema_pb(TabletSchemaPB* tablet_schema_pb) const {
14491484 tablet_schema_pb->mutable_row_store_column_unique_ids ()->Assign (
14501485 _row_store_column_unique_ids.begin (), _row_store_column_unique_ids.end ());
14511486 tablet_schema_pb->set_enable_variant_flatten_nested (_enable_variant_flatten_nested);
1487+ auto column_groups_pb = tablet_schema_pb->mutable_seq_map ();
1488+ for (const auto & it : _seq_map) {
1489+ uint32_t key = it.first ;
1490+ ColumnGroupPB* cg_pb = column_groups_pb->add_cg (); // ColumnGroupPB {key: {v1, v2, v3}}
1491+ cg_pb->set_sequence_column (key);
1492+ for (auto v : it.second ) {
1493+ cg_pb->add_columns_in_group (v);
1494+ }
1495+ }
14521496}
14531497
14541498size_t TabletSchema::row_size () const {
0 commit comments