55 *
66 * The MIT License
77 *
8- * @copyright Copyright (c) 2017-2023 TileDB, Inc.
8+ * @copyright Copyright (c) 2017-2024 TileDB, Inc.
99 *
1010 * Permission is hereby granted, free of charge, to any person obtaining a copy
1111 * of this software and associated documentation files (the "Software"), to deal
@@ -535,28 +535,24 @@ URI ArrayDirectory::get_commits_dir(uint32_t write_version) const {
535535}
536536
537537URI ArrayDirectory::get_commit_uri (const URI& fragment_uri) const {
538- auto name = fragment_uri.remove_trailing_slash ().last_path_part ();
539- auto fragment_version = utils::parse::get_fragment_version (name);
540-
541- if (fragment_version < 12 ) {
538+ FragmentID fragment_id{fragment_uri};
539+ if (fragment_id.array_format_version () < 12 ) {
542540 return URI (fragment_uri.to_string () + constants::ok_file_suffix);
543541 }
544542
545- auto temp_uri =
546- uri_ .join_path (constants::array_commits_dir_name). join_path ( name);
543+ auto temp_uri = uri_. join_path (constants::array_commits_dir_name)
544+ .join_path (fragment_id. name () );
547545 return URI (temp_uri.to_string () + constants::write_file_suffix);
548546}
549547
550548URI ArrayDirectory::get_vacuum_uri (const URI& fragment_uri) const {
551- auto name = fragment_uri.remove_trailing_slash ().last_path_part ();
552- auto fragment_version = utils::parse::get_fragment_version (name);
553-
554- if (fragment_version < 12 ) {
549+ FragmentID fragment_id{fragment_uri};
550+ if (fragment_id.array_format_version () < 12 ) {
555551 return URI (fragment_uri.to_string () + constants::vacuum_file_suffix);
556552 }
557553
558- auto temp_uri =
559- uri_ .join_path (constants::array_commits_dir_name). join_path ( name);
554+ auto temp_uri = uri_. join_path (constants::array_commits_dir_name)
555+ .join_path (fragment_id. name () );
560556 return URI (temp_uri.to_string () + constants::vacuum_file_suffix);
561557}
562558
@@ -678,11 +674,8 @@ ArrayDirectory::load_commits_dir_uris_v12_or_higher(
678674 stdx::string::ends_with (
679675 commits_dir_uris[i].to_string (), constants::update_file_suffix)) {
680676 // Get the start and end timestamp for this delete/update
681- std::pair<uint64_t , uint64_t > timestamp_range;
682- RETURN_NOT_OK_TUPLE (
683- utils::parse::get_timestamp_range (
684- commits_dir_uris[i], ×tamp_range),
685- nullopt );
677+ FragmentID fragment_id{commits_dir_uris[i]};
678+ auto timestamp_range{fragment_id.timestamp_range ()};
686679
687680 // Add the delete tile location if it overlaps the open start/end times
688681 if (timestamps_overlap (timestamp_range, false )) {
@@ -772,12 +765,8 @@ ArrayDirectory::load_consolidated_commit_uris(
772765 auto pos = ss.tellg ();
773766
774767 // Get the start and end timestamp for this delete
775- std::pair<uint64_t , uint64_t > delete_timestamp_range;
776- RETURN_NOT_OK_TUPLE (
777- utils::parse::get_timestamp_range (
778- URI (condition_marker), &delete_timestamp_range),
779- nullopt ,
780- nullopt );
768+ FragmentID fragment_id{URI (condition_marker)};
769+ auto delete_timestamp_range{fragment_id.timestamp_range ()};
781770
782771 // Add the delete tile location if it overlaps the open start/end
783772 // times
@@ -1028,9 +1017,8 @@ ArrayDirectory::compute_uris_to_vacuum(
10281017 auto & uri = uris[i];
10291018
10301019 // Get the start and end timestamp for this fragment
1031- std::pair<uint64_t , uint64_t > fragment_timestamp_range;
1032- RETURN_NOT_OK (
1033- utils::parse::get_timestamp_range (uri, &fragment_timestamp_range));
1020+ FragmentID fragment_id{uri};
1021+ auto fragment_timestamp_range{fragment_id.timestamp_range ()};
10341022 if (is_vacuum_file (uri)) {
10351023 vac_file_bitmap[i] = 1 ;
10361024 if (timestamps_overlap (
@@ -1164,8 +1152,8 @@ ArrayDirectory::compute_filtered_uris(
11641152 }
11651153
11661154 // Get the start and end timestamp for this fragment
1167- RETURN_NOT_OK ( utils::parse::get_timestamp_range (
1168- uri, & fragment_timestamp_ranges[i]) );
1155+ FragmentID fragment_id{uri};
1156+ fragment_timestamp_ranges[i] = fragment_id. timestamp_range ( );
11691157 if (timestamps_overlap (
11701158 fragment_timestamp_ranges[i],
11711159 !full_overlap_only &&
@@ -1238,16 +1226,13 @@ URI ArrayDirectory::select_latest_array_schema_uri() {
12381226 uint64_t latest_ts = 0 ;
12391227
12401228 for (auto & uri : array_schema_uris_) {
1241- auto name = uri.remove_trailing_slash ().last_path_part ();
1242-
1229+ FragmentID fragment_id{uri};
12431230 // Skip the old schema URI name since it doesn't have timestamps
1244- if (name == constants::array_schema_filename) {
1231+ if (fragment_id. name () == constants::array_schema_filename) {
12451232 continue ;
12461233 }
12471234
1248- std::pair<uint64_t , uint64_t > ts_range;
1249- throw_if_not_ok (utils::parse::get_timestamp_range (uri, &ts_range));
1250-
1235+ auto ts_range{fragment_id.timestamp_range ()};
12511236 if (ts_range.second > latest_ts && ts_range.second <= timestamp_end_) {
12521237 latest_uri = uri;
12531238 latest_ts = ts_range.second ;
@@ -1270,7 +1255,8 @@ Status ArrayDirectory::is_fragment(
12701255 const std::unordered_set<std::string>& consolidated_uris_set,
12711256 int * is_fragment) const {
12721257 // If the URI name has a suffix, then it is not a fragment
1273- auto name = uri.remove_trailing_slash ().last_path_part ();
1258+ FragmentID fragment_id{uri};
1259+ auto name = fragment_id.name ();
12741260 if (name.find_first_of (' .' ) != std::string::npos) {
12751261 *is_fragment = 0 ;
12761262 return Status::Ok ();
@@ -1299,10 +1285,9 @@ Status ArrayDirectory::is_fragment(
12991285 return Status::Ok ();
13001286 }
13011287
1302- // If the format version is >= 5, then the above suffices to check if
1288+ // If the array format version is >= 5, then the above suffices to check if
13031289 // the URI is indeed a fragment
1304- auto fragment_version = utils::parse::get_fragment_version (name);
1305- if (fragment_version >= 5 ) {
1290+ if (fragment_id.array_format_version () >= 5 ) {
13061291 *is_fragment = false ;
13071292 return Status::Ok ();
13081293 }
@@ -1317,15 +1302,12 @@ Status ArrayDirectory::is_fragment(
13171302
13181303bool ArrayDirectory::consolidation_with_timestamps_supported (
13191304 const URI& uri) const {
1320- // Get the fragment version from the uri
1321- auto name = uri.remove_trailing_slash ().last_path_part ();
1322- auto fragment_version = utils::parse::get_fragment_version (name);
1323-
1324- // get_fragment_version returns UINT32_MAX for versions <= 2 so we should
1325- // explicitly exclude this case when checking if consolidation with timestamps
1326- // is supported on a fragment
1305+ // FragmentID::array_format_version() returns UINT32_MAX for versions <= 2
1306+ // so we should explicitly exclude this case when checking if consolidation
1307+ // with timestamps is supported on a fragment
1308+ FragmentID fragment_id{uri};
13271309 return mode_ == ArrayDirectoryMode::READ &&
1328- fragment_version >=
1310+ fragment_id. array_format_version () >=
13291311 constants::consolidation_with_timestamps_min_version;
13301312}
13311313
0 commit comments