diff --git a/test/src/unit-capi-array.cc b/test/src/unit-capi-array.cc index 4218f514b6f..a088d2a7614 100644 --- a/test/src/unit-capi-array.cc +++ b/test/src/unit-capi-array.cc @@ -382,7 +382,7 @@ void ArrayFx::create_dense_array(const std::string& path) { void ArrayFx::write_fragment(tiledb_array_t* array, uint64_t timestamp) { // Open the array at the given timestamp - int rc = tiledb_array_set_open_timestamp_start(ctx_, array, timestamp); + int rc = tiledb_array_set_open_timestamp_end(ctx_, array, timestamp); REQUIRE(rc == TILEDB_OK); rc = tiledb_array_open(ctx_, array, TILEDB_WRITE); REQUIRE(rc == TILEDB_OK); @@ -2686,63 +2686,67 @@ TEST_CASE_METHOD( CHECK(tiledb::test::num_commits(array_name) == 2); CHECK(tiledb::test::num_fragments(array_name) == 2); - // Serialize fragment timestamp and deserialize using C API + // ALlocate buffer tiledb_buffer_t* buff; rc = tiledb_buffer_alloc(ctx_, &buff); REQUIRE(rc == TILEDB_OK); - tiledb::sm::serialization::fragments_timestamps_serialize( - array_name, - start_timestamp, - end_timestamp, - tiledb::sm::SerializationType::CAPNP, - &buff->buffer()); - rc = tiledb_deserialize_array_delete_fragments_timestamps_request( - ctx_, - (tiledb_serialization_type_t)tiledb::sm::SerializationType::CAPNP, - buff); - REQUIRE(rc == TILEDB_OK); - // #TODO Update test once cloud-side endpoint is added - // CHECK(tiledb::test::num_commits(array_name) == 0); - // CHECK(tiledb::test::num_fragments(array_name) == 0); - // Get the fragment info object - tiledb_fragment_info_t* fragment_info = nullptr; - rc = tiledb_fragment_info_alloc(ctx_, array_name.c_str(), &fragment_info); - REQUIRE(rc == TILEDB_OK); - rc = tiledb_fragment_info_load(ctx_, fragment_info); - REQUIRE(rc == TILEDB_OK); + SECTION("delete_fragments") { + // Serialize fragment timestamps and deserialize delete request + tiledb::sm::serialization::fragments_timestamps_serialize( + array_name, + start_timestamp, + end_timestamp, + tiledb::sm::SerializationType::CAPNP, + &buff->buffer()); + rc = tiledb_deserialize_array_delete_fragments_timestamps_request( + ctx_, + (tiledb_serialization_type_t)tiledb::sm::SerializationType::CAPNP, + buff); + REQUIRE(rc == TILEDB_OK); + CHECK(tiledb::test::num_commits(array_name) == 0); + CHECK(tiledb::test::num_fragments(array_name) == 0); + } - // Get the fragment URIs - const char* uri1; - rc = tiledb_fragment_info_get_fragment_uri(ctx_, fragment_info, 0, &uri1); - REQUIRE(rc == TILEDB_OK); - const char* uri2; - rc = tiledb_fragment_info_get_fragment_uri(ctx_, fragment_info, 1, &uri2); - REQUIRE(rc == TILEDB_OK); + SECTION("delete_fragments_list") { + // Get the fragment info object + tiledb_fragment_info_t* fragment_info = nullptr; + rc = tiledb_fragment_info_alloc(ctx_, array_name.c_str(), &fragment_info); + REQUIRE(rc == TILEDB_OK); + rc = tiledb_fragment_info_load(ctx_, fragment_info); + REQUIRE(rc == TILEDB_OK); - std::vector fragments; - fragments.emplace_back(URI(uri1)); - fragments.emplace_back(URI(uri2)); + // Get the fragment URIs + const char* uri1; + rc = tiledb_fragment_info_get_fragment_uri(ctx_, fragment_info, 0, &uri1); + REQUIRE(rc == TILEDB_OK); + const char* uri2; + rc = tiledb_fragment_info_get_fragment_uri(ctx_, fragment_info, 1, &uri2); + REQUIRE(rc == TILEDB_OK); - // Serialize fragments list and deserialize using C API - tiledb::sm::serialization::fragments_list_serialize( - array_name, - fragments, - tiledb::sm::SerializationType::CAPNP, - &buff->buffer()); - rc = tiledb_deserialize_array_delete_fragments_list_request( - ctx_, - (tiledb_serialization_type_t)tiledb::sm::SerializationType::CAPNP, - buff); - REQUIRE(rc == TILEDB_OK); - // #TODO Update test once cloud-side endpoint is added - // CHECK(tiledb::test::num_commits(array_name) == 0); - // CHECK(tiledb::test::num_fragments(array_name) == 0); + std::vector fragments; + fragments.emplace_back(URI(uri1)); + fragments.emplace_back(URI(uri2)); + + // Serialize fragments list and deserialize delete request + tiledb::sm::serialization::fragments_list_serialize( + array_name, + fragments, + tiledb::sm::SerializationType::CAPNP, + &buff->buffer()); + rc = tiledb_deserialize_array_delete_fragments_list_request( + ctx_, + (tiledb_serialization_type_t)tiledb::sm::SerializationType::CAPNP, + buff); + REQUIRE(rc == TILEDB_OK); + CHECK(tiledb::test::num_commits(array_name) == 0); + CHECK(tiledb::test::num_fragments(array_name) == 0); + tiledb_fragment_info_free(&fragment_info); + } // Clean up tiledb_array_free(&array); tiledb_buffer_free(&buff); - tiledb_fragment_info_free(&fragment_info); remove_temp_dir(local_fs.file_prefix() + local_fs.temp_dir()); #endif } diff --git a/test/src/unit-cppapi-deletes.cc b/test/src/unit-cppapi-deletes.cc index 0033000f29c..8306717301a 100644 --- a/test/src/unit-cppapi-deletes.cc +++ b/test/src/unit-cppapi-deletes.cc @@ -1825,7 +1825,7 @@ TEST_CASE_METHOD( // Delete fragments SECTION("delete fragments by timestamps") { - Array::delete_fragments_v2(ctx_, SPARSE_ARRAY_NAME, 2, 6); + Array::delete_fragments(ctx_, SPARSE_ARRAY_NAME, 2, 6); } SECTION("delete fragments by uris") { @@ -1912,7 +1912,7 @@ TEST_CASE_METHOD( CHECK(tiledb::test::num_fragments(SPARSE_ARRAY_NAME) == num_fragments); // Delete fragments at timestamps 2 - 4 - Array::delete_fragments_v2(ctx_, SPARSE_ARRAY_NAME, 2, 4); + Array::delete_fragments(ctx_, SPARSE_ARRAY_NAME, 2, 4); if (!vacuum) { // Vacuum after deletion auto config = ctx_.config(); diff --git a/tiledb/sm/c_api/tiledb.cc b/tiledb/sm/c_api/tiledb.cc index cc47f5b2e11..95e4d4667c8 100644 --- a/tiledb/sm/c_api/tiledb.cc +++ b/tiledb/sm/c_api/tiledb.cc @@ -2391,6 +2391,10 @@ capi_return_t tiledb_array_delete_fragments_v2( throw api::CAPIStatusException("Failed to create array"); } + // Set array open timestamps + array->array_->set_timestamp_start(timestamp_start); + array->array_->set_timestamp_end(timestamp_end); + // Open the array for exclusive modification throw_if_not_ok(array->array_->open( static_cast(TILEDB_MODIFY_EXCLUSIVE), @@ -4076,6 +4080,10 @@ capi_return_t tiledb_deserialize_array_delete_fragments_timestamps_request( throw api::CAPIStatusException("Failed to create array"); } + // Set array open timestamps + array->array_->set_timestamp_start(timestamp_start); + array->array_->set_timestamp_end(timestamp_end); + // Open the array for exclusive modification throw_if_not_ok(array->array_->open( static_cast(TILEDB_MODIFY_EXCLUSIVE), diff --git a/tiledb/sm/cpp_api/array.h b/tiledb/sm/cpp_api/array.h index 368c1a81199..b11d0b9af4d 100644 --- a/tiledb/sm/cpp_api/array.h +++ b/tiledb/sm/cpp_api/array.h @@ -360,8 +360,8 @@ class Array { uint64_t timestamp_start, uint64_t timestamp_end) const { throw std::logic_error( - "Array::delete_fragments is deprecated. Please use " - "Array::delete_fragments_v2 instead."); + "This method is deprecated. Please use " + "Array::delete_fragments(ctx, uri, timestamp_start, timestamp_end)"); auto& ctx = ctx_.get(); ctx.handle_error(tiledb_array_delete_fragments_v2( ctx.ptr().get(), uri.c_str(), timestamp_start, timestamp_end)); @@ -377,7 +377,7 @@ class Array { * @param timestamp_end The epoch end timestamp in milliseconds. Use * UINT64_MAX for the current timestamp. */ - static void delete_fragments_v2( + static void delete_fragments( const Context& ctx, const std::string& uri, uint64_t timestamp_start,