@@ -1302,15 +1302,33 @@ void TabletSchema::build_current_tablet_schema(int64_t index_id, int32_t version
13021302 } else if (UNLIKELY (column->name () == SKIP_BITMAP_COL)) {
13031303 _skip_bitmap_col_idx = _num_columns;
13041304 }
1305- _cols.emplace_back (std::make_shared<TabletColumn>(*column));
1305+ // Reuse TabletColumn object from pool to reduce memory consumption
1306+ TabletColumnPtr new_column;
1307+ ColumnPB column_pb;
1308+ column->to_schema_pb (&column_pb);
1309+ auto pair = TabletColumnObjectPool::instance ()->insert (
1310+ deterministic_string_serialize (column_pb));
1311+ new_column = pair.second ;
1312+ // Release the handle quickly, because we use shared ptr to manage column
1313+ TabletColumnObjectPool::instance ()->release (pair.first );
1314+ _cols.emplace_back (std::move (new_column));
13061315 _field_name_to_index.emplace (StringRef (_cols.back ()->name ()), _num_columns);
13071316 _field_uniqueid_to_index[_cols.back ()->unique_id ()] = _num_columns;
13081317 _num_columns++;
13091318 }
13101319
13111320 for (const auto & i : index->indexes ) {
13121321 size_t index_pos = _indexes.size ();
1313- _indexes.emplace_back (std::make_shared<TabletIndex>(*i));
1322+ // Reuse TabletIndex object from pool to reduce memory consumption
1323+ TabletIndexPtr new_index;
1324+ TabletIndexPB index_pb;
1325+ i->to_schema_pb (&index_pb);
1326+ auto pair = TabletColumnObjectPool::instance ()->insert_index (
1327+ deterministic_string_serialize (index_pb));
1328+ new_index = pair.second ;
1329+ // Release the handle quickly, because we use shared ptr to manage index
1330+ TabletColumnObjectPool::instance ()->release (pair.first );
1331+ _indexes.emplace_back (std::move (new_index));
13141332 for (int32_t col_uid : _indexes.back ()->col_unique_ids ()) {
13151333 if (auto field_pattern = _indexes.back ()->field_pattern (); !field_pattern.empty ()) {
13161334 auto & pattern_to_index_map = _index_by_unique_id_with_pattern[col_uid];
0 commit comments