@@ -1193,6 +1193,41 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& schema, bool ignore_extrac
11931193 _storage_page_size = schema.storage_page_size ();
11941194 _storage_dict_page_size = schema.storage_dict_page_size ();
11951195 _schema_version = schema.schema_version ();
1196+ auto column_groups_pb = schema.seq_map ();
1197+ _seq_map.clear ();
1198+ _value_to_seq.clear ();
1199+ /*
1200+ * ColumnGroupsPB is a list of cg_pb, and
1201+ * ColumnGroupsPB do not have begin() or end() method.
1202+ * we must use for(i=0;i<xx;i++) loop
1203+ */
1204+ for (int i = 0 ; i < column_groups_pb.cg_size (); i++) {
1205+ ColumnGroupPB cg_pb = column_groups_pb.cg (i);
1206+ uint32_t key = cg_pb.sequence_column ();
1207+ for (auto j : cg_pb.columns_in_group ()) {
1208+ _seq_map[key].push_back (j);
1209+ }
1210+ }
1211+
1212+ if (_seq_map.size () > 0 ) {
1213+ /*
1214+ |** KEY **| ** VALUE ** |
1215+ ------------------------------------
1216+ |** KEY **| CDE is value| sequence|
1217+ |----|----|----|----|----|----|----|
1218+ A B C D E S1 S2
1219+ 0 1 2 3 4 5 6
1220+ for example: _seq_map is {5:{2,3}, 6:{4}}
1221+ then, _value_to_seq = {2:5,3:5,5:5,4:6,6:6}
1222+ */
1223+ for (auto it = _seq_map.cbegin (); it != _seq_map.cend (); it++) {
1224+ auto k = it->first ;
1225+ for (auto v : it->second ) {
1226+ _value_to_seq[v] = k;
1227+ }
1228+ _value_to_seq[k] = k;
1229+ }
1230+ }
11961231 // Default to V1 inverted index storage format for backward compatibility if not specified in schema.
11971232 if (!schema.has_inverted_index_storage_format ()) {
11981233 _inverted_index_storage_format = InvertedIndexStorageFormatPB::V1;
@@ -1456,6 +1491,15 @@ void TabletSchema::to_schema_pb(TabletSchemaPB* tablet_schema_pb) const {
14561491 tablet_schema_pb->mutable_row_store_column_unique_ids ()->Assign (
14571492 _row_store_column_unique_ids.begin (), _row_store_column_unique_ids.end ());
14581493 tablet_schema_pb->set_enable_variant_flatten_nested (_enable_variant_flatten_nested);
1494+ auto column_groups_pb = tablet_schema_pb->mutable_seq_map ();
1495+ for (const auto & it : _seq_map) {
1496+ uint32_t key = it.first ;
1497+ ColumnGroupPB* cg_pb = column_groups_pb->add_cg (); // ColumnGroupPB {key: {v1, v2, v3}}
1498+ cg_pb->set_sequence_column (key);
1499+ for (auto v : it.second ) {
1500+ cg_pb->add_columns_in_group (v);
1501+ }
1502+ }
14591503}
14601504
14611505size_t TabletSchema::row_size () const {
0 commit comments