Skip to content

Commit

Permalink
Update LoadedFragmentMetadata::create to return a shared pointer. (#…
Browse files Browse the repository at this point in the history
…5214)

[SC-51612](https://app.shortcut.com/tiledb-inc/story/51612/use-make-shared-to-create-loadedfragmentmetadata)

Using `make_shared` to create the shared pointer is more efficient
because the control plane is located next to the object.

---
TYPE: NO_HISTORY
  • Loading branch information
teo-tsirpanis authored Aug 15, 2024
1 parent bcf0144 commit 2c7812a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tiledb/sm/fragment/loaded_fragment_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ LoadedFragmentMetadata::LoadedFragmentMetadata(
/* API */
/* ********************************* */

LoadedFragmentMetadata* LoadedFragmentMetadata::create(
shared_ptr<LoadedFragmentMetadata> LoadedFragmentMetadata::create(
FragmentMetadata& parent,
shared_ptr<MemoryTracker> memory_tracker,
format_version_t version) {
if (version <= 2) {
return tdb_new(V1V2PreloadedFragmentMetadata, parent, memory_tracker);
return make_shared<V1V2PreloadedFragmentMetadata>(
HERE(), parent, memory_tracker);
}

return tdb_new(OndemandFragmentMetadata, parent, memory_tracker);
return make_shared<OndemandFragmentMetadata>(HERE(), parent, memory_tracker);
}

uint64_t LoadedFragmentMetadata::persisted_tile_size(
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/fragment/loaded_fragment_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LoadedFragmentMetadata {
* metadata corresponds to.
* @param version The format version of the fragment
*/
static LoadedFragmentMetadata* create(
static shared_ptr<LoadedFragmentMetadata> create(
FragmentMetadata& parent,
shared_ptr<MemoryTracker> memory_tracker,
format_version_t version);
Expand Down

0 comments on commit 2c7812a

Please sign in to comment.