This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 4a8fa8c4c36 branch-3.0: [Optimize](TabletMeta) Reuse TabletSchema in TabletMeta #46572 (#46686) 4a8fa8c4c36 is described below commit 4a8fa8c4c360f8b40d04aa5eaac24a4d43f1af15 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Mon Jan 13 21:28:09 2025 +0800 branch-3.0: [Optimize](TabletMeta) Reuse TabletSchema in TabletMeta #46572 (#46686) Cherry-picked from #46572 Co-authored-by: lihangyu <lihan...@selectdb.com> --- be/src/olap/tablet_meta.cpp | 18 +++++++++++++++++- be/src/olap/tablet_meta.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/be/src/olap/tablet_meta.cpp b/be/src/olap/tablet_meta.cpp index 655da615f95..51e1eb38421 100644 --- a/be/src/olap/tablet_meta.cpp +++ b/be/src/olap/tablet_meta.cpp @@ -27,6 +27,7 @@ #include <time.h> #include <cstdint> +#include <memory> #include <set> #include <utility> @@ -43,7 +44,9 @@ #include "olap/olap_define.h" #include "olap/rowset/rowset.h" #include "olap/rowset/rowset_meta_manager.h" +#include "olap/tablet_fwd.h" #include "olap/tablet_meta_manager.h" +#include "olap/tablet_schema_cache.h" #include "olap/utils.h" #include "util/debug_points.h" #include "util/mem_info.h" @@ -101,6 +104,12 @@ TabletMetaSharedPtr TabletMeta::create( request.time_series_compaction_level_threshold, inverted_index_file_storage_format); } +TabletMeta::~TabletMeta() { + if (_handle) { + TabletSchemaCache::instance()->release(_handle); + } +} + TabletMeta::TabletMeta() : _tablet_uid(0, 0), _schema(new TabletSchema), @@ -622,7 +631,14 @@ void TabletMeta::init_from_pb(const TabletMetaPB& tablet_meta_pb) { } // init _schema - _schema->init_from_pb(tablet_meta_pb.schema()); + TabletSchemaSPtr schema = std::make_shared<TabletSchema>(); + schema->init_from_pb(tablet_meta_pb.schema()); + if (_handle) { + TabletSchemaCache::instance()->release(_handle); + } + auto pair = TabletSchemaCache::instance()->insert(schema->to_key()); + _handle = pair.first; + _schema = pair.second; if (tablet_meta_pb.has_enable_unique_key_merge_on_write()) { _enable_unique_key_merge_on_write = tablet_meta_pb.enable_unique_key_merge_on_write(); diff --git a/be/src/olap/tablet_meta.h b/be/src/olap/tablet_meta.h index 550c478694f..ef4dbfba44c 100644 --- a/be/src/olap/tablet_meta.h +++ b/be/src/olap/tablet_meta.h @@ -100,6 +100,7 @@ public: const std::unordered_map<uint32_t, uint32_t>& col_ordinal_to_unique_id); TabletMeta(); + ~TabletMeta() override; TabletMeta(int64_t table_id, int64_t partition_id, int64_t tablet_id, int64_t replica_id, int32_t schema_hash, int32_t shard_id, const TTabletSchema& tablet_schema, uint32_t next_unique_id, @@ -324,6 +325,7 @@ private: // the reference of _schema may use in tablet, so here need keep // the lifetime of tablemeta and _schema is same with tablet TabletSchemaSPtr _schema; + Cache::Handle* _handle = nullptr; std::vector<RowsetMetaSharedPtr> _rs_metas; // This variable _stale_rs_metas is used to record these rowsets‘ meta which are be compacted. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org