From 6becb297e4d8730b1774e25a353c496e706cd9db Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 30 Sep 2024 12:48:52 +0300 Subject: [PATCH 1/2] Add overload to `Array::create` that explicitly accepts a context. --- tiledb/sm/cpp_api/array.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tiledb/sm/cpp_api/array.h b/tiledb/sm/cpp_api/array.h index 975a76d55a5..6ef99ad961c 100644 --- a/tiledb/sm/cpp_api/array.h +++ b/tiledb/sm/cpp_api/array.h @@ -663,20 +663,40 @@ class Array { * * **Example:** * @code{.cpp} - * tiledb::Array::create("s3://bucket-name/array-name", schema); + * tiledb::Array::create(ctx, "s3://bucket-name/array-name", schema); * @endcode * + * @param ctx The TileDB context. * @param uri URI where array will be created. * @param schema The array schema. */ - static void create(const std::string& uri, const ArraySchema& schema) { - auto& ctx = schema.context(); + static void create( + const Context& ctx, const std::string& uri, const ArraySchema& schema) { tiledb_ctx_t* c_ctx = ctx.ptr().get(); ctx.handle_error(tiledb_array_schema_check(c_ctx, schema.ptr().get())); ctx.handle_error( tiledb_array_create(c_ctx, uri.c_str(), schema.ptr().get())); } + /** + * Creates a new TileDB array given an input schema. + * + * To create the array, this function uses the context that was used to + * instantiate the schema. You are recommended to explicitly pass it with the + * overload that takes a context. + * + * **Example:** + * @code{.cpp} + * tiledb::Array::create("s3://bucket-name/array-name", schema); + * @endcode + * + * @param uri URI where array will be created. + * @param schema The array schema. + */ + static void create(const std::string& uri, const ArraySchema& schema) { + create(schema.context(), uri, schema); + } + /** * Loads the array schema from an array. * From a19f6e1351e67133faa5d89fb83484c637180df5 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 30 Sep 2024 17:13:26 +0300 Subject: [PATCH 2/2] Update all C++ examples and `unit-cppapi-array` to use the new API. --- examples/cpp_api/aggregates.cc | 2 +- examples/cpp_api/array_metadata.cc | 2 +- examples/cpp_api/array_schema_evolution.cc | 2 +- examples/cpp_api/axes_labels.cc | 4 +- examples/cpp_api/consolidation_plan.cc | 2 +- examples/cpp_api/current_domain.cc | 2 +- examples/cpp_api/deletes.cc | 2 +- examples/cpp_api/encryption.cc | 2 +- examples/cpp_api/enumerations.cc | 2 +- examples/cpp_api/filters.cc | 2 +- examples/cpp_api/fragment_info.cc | 2 +- examples/cpp_api/fragments_consolidation.cc | 2 +- examples/cpp_api/groups.cc | 2 +- examples/cpp_api/multi_attribute.cc | 2 +- examples/cpp_api/multi_range_subarray.cc | 2 +- examples/cpp_api/nullable_attribute.cc | 2 +- examples/cpp_api/object.cc | 2 +- examples/cpp_api/png_ingestion_webp.cc | 2 +- examples/cpp_api/query_condition_dense.cc | 2 +- examples/cpp_api/query_condition_sparse.cc | 2 +- examples/cpp_api/quickstart_dense.cc | 2 +- .../cpp_api/quickstart_dimension_labels.cc | 2 +- examples/cpp_api/quickstart_sparse.cc | 2 +- examples/cpp_api/quickstart_sparse_heter.cc | 2 +- examples/cpp_api/quickstart_sparse_string.cc | 2 +- examples/cpp_api/reading_dense_layouts.cc | 2 +- examples/cpp_api/reading_incomplete.cc | 2 +- examples/cpp_api/reading_sparse_layouts.cc | 2 +- examples/cpp_api/using_tiledb_stats.cc | 2 +- examples/cpp_api/variable_length.cc | 2 +- examples/cpp_api/writing_dense_global.cc | 2 +- .../cpp_api/writing_dense_global_expansion.cc | 2 +- examples/cpp_api/writing_dense_multiple.cc | 2 +- examples/cpp_api/writing_dense_padding.cc | 2 +- examples/cpp_api/writing_sparse_global.cc | 2 +- examples/cpp_api/writing_sparse_multiple.cc | 2 +- examples/png_ingestion/src/main.cc | 2 +- test/src/unit-cppapi-array.cc | 51 ++++++++++--------- 38 files changed, 64 insertions(+), 63 deletions(-) diff --git a/examples/cpp_api/aggregates.cc b/examples/cpp_api/aggregates.cc index 294ebfbf735..9241f3493aa 100644 --- a/examples/cpp_api/aggregates.cc +++ b/examples/cpp_api/aggregates.cc @@ -61,7 +61,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/array_metadata.cc b/examples/cpp_api/array_metadata.cc index dca4fcb5faf..9102496490c 100644 --- a/examples/cpp_api/array_metadata.cc +++ b/examples/cpp_api/array_metadata.cc @@ -56,7 +56,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array_metadata() { diff --git a/examples/cpp_api/array_schema_evolution.cc b/examples/cpp_api/array_schema_evolution.cc index 495c80321b5..13e77a2dacb 100644 --- a/examples/cpp_api/array_schema_evolution.cc +++ b/examples/cpp_api/array_schema_evolution.cc @@ -55,7 +55,7 @@ void create_array(const Context& ctx) { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); } void write_array(const Context& ctx) { diff --git a/examples/cpp_api/axes_labels.cc b/examples/cpp_api/axes_labels.cc index ee775908d32..6e629c70b5d 100644 --- a/examples/cpp_api/axes_labels.cc +++ b/examples/cpp_api/axes_labels.cc @@ -71,7 +71,7 @@ void create_data_array(tiledb::Context& ctx, const std::string& array_uri) { schema.set_allows_dups(false); // Create the (empty) array on disk. - tiledb::Array::create(array_uri, schema); + tiledb::Array::create(ctx, array_uri, schema); } void create_axes_array(tiledb::Context& ctx, const std::string& array_uri) { @@ -96,7 +96,7 @@ void create_axes_array(tiledb::Context& ctx, const std::string& array_uri) { schema.set_allows_dups(true); // Create the (empty) array on disk. - tiledb::Array::create(array_uri, schema); + tiledb::Array::create(ctx, array_uri, schema); } void write_axes_array(tiledb::Context& ctx, const std::string& array_uri) { diff --git a/examples/cpp_api/consolidation_plan.cc b/examples/cpp_api/consolidation_plan.cc index 1754528b211..fc2b0617591 100644 --- a/examples/cpp_api/consolidation_plan.cc +++ b/examples/cpp_api/consolidation_plan.cc @@ -61,7 +61,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_fragment(int min, int max) { diff --git a/examples/cpp_api/current_domain.cc b/examples/cpp_api/current_domain.cc index 3ba4be14a75..400b2952293 100644 --- a/examples/cpp_api/current_domain.cc +++ b/examples/cpp_api/current_domain.cc @@ -76,7 +76,7 @@ void create_array(Context& ctx, const std::string& array_uri) { ArraySchemaExperimental::set_current_domain(ctx, schema, current_domain); // Create the (empty) array on disk - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); } void print_current_domain(Context& ctx) { diff --git a/examples/cpp_api/deletes.cc b/examples/cpp_api/deletes.cc index 89a19e241dc..944d58feb6b 100644 --- a/examples/cpp_api/deletes.cc +++ b/examples/cpp_api/deletes.cc @@ -56,7 +56,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/encryption.cc b/examples/cpp_api/encryption.cc index c3ca1760491..ae87a130310 100644 --- a/examples/cpp_api/encryption.cc +++ b/examples/cpp_api/encryption.cc @@ -63,7 +63,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) encrypted array. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/enumerations.cc b/examples/cpp_api/enumerations.cc index ea439d181c8..acd193a0ec7 100644 --- a/examples/cpp_api/enumerations.cc +++ b/examples/cpp_api/enumerations.cc @@ -79,7 +79,7 @@ void create_array() { // Finally, we add the attribute as per normal. schema.add_attribute(attr); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/filters.cc b/examples/cpp_api/filters.cc index 3efd7128118..8d6ff5c4d28 100644 --- a/examples/cpp_api/filters.cc +++ b/examples/cpp_api/filters.cc @@ -73,7 +73,7 @@ void create_array() { schema.add_attribute(a1).add_attribute(a2); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/fragment_info.cc b/examples/cpp_api/fragment_info.cc index 298ee265900..c37370956f3 100644 --- a/examples/cpp_api/fragment_info.cc +++ b/examples/cpp_api/fragment_info.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/fragments_consolidation.cc b/examples/cpp_api/fragments_consolidation.cc index bad0769afee..0415a1ba3ef 100644 --- a/examples/cpp_api/fragments_consolidation.cc +++ b/examples/cpp_api/fragments_consolidation.cc @@ -58,7 +58,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array_1() { diff --git a/examples/cpp_api/groups.cc b/examples/cpp_api/groups.cc index cc73391a9ac..1f806a97d66 100644 --- a/examples/cpp_api/groups.cc +++ b/examples/cpp_api/groups.cc @@ -59,7 +59,7 @@ void create_array(const std::string& array_name, tiledb_array_type_t type) { ArraySchema schema(ctx, type); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void create_arrays_groups() { diff --git a/examples/cpp_api/multi_attribute.cc b/examples/cpp_api/multi_attribute.cc index 29d490e6e51..5710889a8e7 100644 --- a/examples/cpp_api/multi_attribute.cc +++ b/examples/cpp_api/multi_attribute.cc @@ -63,7 +63,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a2")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/multi_range_subarray.cc b/examples/cpp_api/multi_range_subarray.cc index 9bc73516e59..49c0379d5a6 100644 --- a/examples/cpp_api/multi_range_subarray.cc +++ b/examples/cpp_api/multi_range_subarray.cc @@ -56,7 +56,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/nullable_attribute.cc b/examples/cpp_api/nullable_attribute.cc index e0ab361ff4b..a15989d69c6 100644 --- a/examples/cpp_api/nullable_attribute.cc +++ b/examples/cpp_api/nullable_attribute.cc @@ -70,7 +70,7 @@ void create_array() { schema.add_attribute(a3); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/object.cc b/examples/cpp_api/object.cc index ac7a60af919..0bab034de82 100644 --- a/examples/cpp_api/object.cc +++ b/examples/cpp_api/object.cc @@ -98,7 +98,7 @@ void create_array(const std::string& array_name, tiledb_array_type_t type) { ArraySchema schema(ctx, type); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void move_remove_obj() { diff --git a/examples/cpp_api/png_ingestion_webp.cc b/examples/cpp_api/png_ingestion_webp.cc index 953c3cc4e9e..40cd4b34a3f 100644 --- a/examples/cpp_api/png_ingestion_webp.cc +++ b/examples/cpp_api/png_ingestion_webp.cc @@ -236,7 +236,7 @@ void create_array( schema.add_attribute(rgba); // Create the empty array on disk. - Array::create(array_path, schema); + Array::create(ctx, array_path, schema); } /** diff --git a/examples/cpp_api/query_condition_dense.cc b/examples/cpp_api/query_condition_dense.cc index d8d0da337e5..c635ae035fd 100644 --- a/examples/cpp_api/query_condition_dense.cc +++ b/examples/cpp_api/query_condition_dense.cc @@ -98,7 +98,7 @@ void create_array(Context& ctx) { schema.add_attribute(a).add_attribute(b).add_attribute(c).add_attribute(d); // Create the (empty) array. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } /** diff --git a/examples/cpp_api/query_condition_sparse.cc b/examples/cpp_api/query_condition_sparse.cc index af4fd8506b6..35376873d69 100644 --- a/examples/cpp_api/query_condition_sparse.cc +++ b/examples/cpp_api/query_condition_sparse.cc @@ -92,7 +92,7 @@ void create_array(Context& ctx) { .add_attribute(Attribute::create(ctx, "d")); // Create the (empty) array. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } /** diff --git a/examples/cpp_api/quickstart_dense.cc b/examples/cpp_api/quickstart_dense.cc index 2c0a3efe6a1..5e93ca93ae8 100644 --- a/examples/cpp_api/quickstart_dense.cc +++ b/examples/cpp_api/quickstart_dense.cc @@ -55,7 +55,7 @@ void create_array(const Context& ctx) { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name_, schema); + Array::create(ctx, array_name_, schema); } void write_array(const Context& ctx) { diff --git a/examples/cpp_api/quickstart_dimension_labels.cc b/examples/cpp_api/quickstart_dimension_labels.cc index e15948338ba..44083d394f5 100644 --- a/examples/cpp_api/quickstart_dimension_labels.cc +++ b/examples/cpp_api/quickstart_dimension_labels.cc @@ -121,7 +121,7 @@ void create_array(const Context& ctx, const char* array_uri) { ctx, schema, 0, "y", TILEDB_INCREASING_DATA, TILEDB_FLOAT64); ArraySchemaExperimental::add_dimension_label( ctx, schema, 1, "timestamp", TILEDB_INCREASING_DATA, TILEDB_DATETIME_SEC); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); } /** diff --git a/examples/cpp_api/quickstart_sparse.cc b/examples/cpp_api/quickstart_sparse.cc index 8173ac8dbd8..cafe218f015 100644 --- a/examples/cpp_api/quickstart_sparse.cc +++ b/examples/cpp_api/quickstart_sparse.cc @@ -56,7 +56,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/quickstart_sparse_heter.cc b/examples/cpp_api/quickstart_sparse_heter.cc index 23e9609f654..d7bee6df469 100644 --- a/examples/cpp_api/quickstart_sparse_heter.cc +++ b/examples/cpp_api/quickstart_sparse_heter.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/quickstart_sparse_string.cc b/examples/cpp_api/quickstart_sparse_string.cc index 8d30a9200ad..21632f93847 100644 --- a/examples/cpp_api/quickstart_sparse_string.cc +++ b/examples/cpp_api/quickstart_sparse_string.cc @@ -61,7 +61,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/reading_dense_layouts.cc b/examples/cpp_api/reading_dense_layouts.cc index 001a4c559ed..c0909ec4c73 100644 --- a/examples/cpp_api/reading_dense_layouts.cc +++ b/examples/cpp_api/reading_dense_layouts.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/reading_incomplete.cc b/examples/cpp_api/reading_incomplete.cc index fe7be801bef..3f75cada0b5 100644 --- a/examples/cpp_api/reading_incomplete.cc +++ b/examples/cpp_api/reading_incomplete.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a2")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/reading_sparse_layouts.cc b/examples/cpp_api/reading_sparse_layouts.cc index 17a485d1040..70b49cf252a 100644 --- a/examples/cpp_api/reading_sparse_layouts.cc +++ b/examples/cpp_api/reading_sparse_layouts.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/using_tiledb_stats.cc b/examples/cpp_api/using_tiledb_stats.cc index 351cdaf3340..8444d3d16ad 100644 --- a/examples/cpp_api/using_tiledb_stats.cc +++ b/examples/cpp_api/using_tiledb_stats.cc @@ -56,7 +56,7 @@ void create_array(uint32_t row_tile_extent, uint32_t col_tile_extent) { schema.set_domain(dom); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/variable_length.cc b/examples/cpp_api/variable_length.cc index 54a98b08c16..deb68ca1167 100644 --- a/examples/cpp_api/variable_length.cc +++ b/examples/cpp_api/variable_length.cc @@ -59,7 +59,7 @@ void create_array() { schema.add_attribute(Attribute::create>(ctx, "a2")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/writing_dense_global.cc b/examples/cpp_api/writing_dense_global.cc index 210b35f0e75..691a5f52acd 100644 --- a/examples/cpp_api/writing_dense_global.cc +++ b/examples/cpp_api/writing_dense_global.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/writing_dense_global_expansion.cc b/examples/cpp_api/writing_dense_global_expansion.cc index ccd57cd5746..37d829826fb 100644 --- a/examples/cpp_api/writing_dense_global_expansion.cc +++ b/examples/cpp_api/writing_dense_global_expansion.cc @@ -59,7 +59,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array_global() { diff --git a/examples/cpp_api/writing_dense_multiple.cc b/examples/cpp_api/writing_dense_multiple.cc index 0b63dc830fb..c56b9f39d38 100644 --- a/examples/cpp_api/writing_dense_multiple.cc +++ b/examples/cpp_api/writing_dense_multiple.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array_1() { diff --git a/examples/cpp_api/writing_dense_padding.cc b/examples/cpp_api/writing_dense_padding.cc index ee30fac0a4c..c9e5e8574b6 100644 --- a/examples/cpp_api/writing_dense_padding.cc +++ b/examples/cpp_api/writing_dense_padding.cc @@ -57,7 +57,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/writing_sparse_global.cc b/examples/cpp_api/writing_sparse_global.cc index 40778f65bf8..92ada0661a4 100644 --- a/examples/cpp_api/writing_sparse_global.cc +++ b/examples/cpp_api/writing_sparse_global.cc @@ -60,7 +60,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/cpp_api/writing_sparse_multiple.cc b/examples/cpp_api/writing_sparse_multiple.cc index 6c66e3475da..3282df8969b 100644 --- a/examples/cpp_api/writing_sparse_multiple.cc +++ b/examples/cpp_api/writing_sparse_multiple.cc @@ -56,7 +56,7 @@ void create_array() { schema.add_attribute(Attribute::create(ctx, "a")); // Create the (empty) array on disk. - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); } void write_array() { diff --git a/examples/png_ingestion/src/main.cc b/examples/png_ingestion/src/main.cc index 69d6f118677..dcad518d7c9 100644 --- a/examples/png_ingestion/src/main.cc +++ b/examples/png_ingestion/src/main.cc @@ -189,7 +189,7 @@ void create_array( .add_attribute(Attribute::create(ctx, "alpha")); // Create the (empty) array on disk. - Array::create(array_path, schema); + Array::create(ctx, array_path, schema); } /** diff --git a/test/src/unit-cppapi-array.cc b/test/src/unit-cppapi-array.cc index c7f5487b1e3..88c8ec291e0 100644 --- a/test/src/unit-cppapi-array.cc +++ b/test/src/unit-cppapi-array.cc @@ -75,7 +75,7 @@ struct CPPArrayFx { schema.add_attributes(a1, a2, a3, a4, a5); // set the array_uri so that it's deleted on cleanup - Array::create(array_uri_, schema); + Array::create(ctx, array_uri_, schema); } test::VFSTestSetup vfs_test_setup_; @@ -135,7 +135,7 @@ TEST_CASE_METHOD(CPPArrayFx, "C++ API: Arrays", "[cppapi][basic][rest]") { schema.set_domain(domain); schema.add_attribute(a1); - Array::create(array_uri1, schema); + Array::create(ctx, array_uri1, schema); Array array(ctx1, array_uri1, TILEDB_READ); // Check that the config values are correct @@ -473,7 +473,7 @@ TEST_CASE( schema.set_domain(domain); schema.add_attribute(Attribute::create>(ctx, "a")); schema.add_attribute(Attribute::create(ctx, "b")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); { Array array(ctx, array_uri, TILEDB_WRITE); @@ -548,7 +548,7 @@ TEST_CASE("C++ API: Incorrect offsets", "[cppapi][invalid-offsets][rest]") { domain.add_dimension(Dimension::create(ctx, "d", {{0, 1000}}, 1001)); schema.set_domain(domain); schema.add_attribute(Attribute::create>(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); Array array(ctx, array_uri, TILEDB_WRITE); std::vector a, coord = {10, 20, 30}; @@ -594,7 +594,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{tile_layout, cell_layout}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); // Write std::vector data_w = { @@ -650,7 +650,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); REQUIRE_NOTHROW(Array::consolidate(ctx, array_name)); @@ -680,7 +680,7 @@ TEST_CASE( schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - tiledb::Array::create(array_name, schema); + tiledb::Array::create(ctx, array_name, schema); auto array_w = tiledb::Array(ctx, array_name, TILEDB_WRITE); std::vector data = {0, 1}; @@ -736,7 +736,7 @@ TEST_CASE("C++ API: Encrypted array", "[cppapi][encryption][non-rest]") { REQUIRE_THROWS_AS( Array::encryption_type(ctx, array_name), tiledb::TileDBError); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); REQUIRE(Array::encryption_type(ctx, array_name) == TILEDB_AES_256_GCM); ArraySchema schema_read(ctx, array_name); @@ -827,7 +827,7 @@ TEST_CASE( REQUIRE_THROWS_AS( Array::encryption_type(ctx, array_name), tiledb::TileDBError); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); REQUIRE(Array::encryption_type(ctx, array_name) == TILEDB_AES_256_GCM); ArraySchema schema_read(ctx, array_name); @@ -893,7 +893,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain); schema.add_attribute(Attribute::create(ctx, "")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); Array array(ctx, array_uri, TILEDB_READ); auto reloaded_schema = array.schema(); @@ -914,7 +914,7 @@ TEST_CASE("C++ API: Open array at", "[cppapi][open-array-at][rest]") { ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write array Array array_w(ctx, array_uri, TILEDB_WRITE); @@ -1023,7 +1023,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); // Write array Array array_w(ctx, array_name, TILEDB_WRITE); @@ -1121,7 +1121,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_SPARSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::vector data_w = {1}; @@ -1172,7 +1172,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a", datatype)); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::byte data_w{1}; @@ -1213,6 +1213,7 @@ TEST_CASE( .set_filter_list(FilterList(ctx).add_filter( Filter(ctx, TILEDB_FILTER_BZIP2))); Array::create( + ctx, array_uri, ArraySchema(ctx, TILEDB_SPARSE) .set_domain(Domain(ctx).add_dimension( @@ -1271,7 +1272,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_SPARSE); schema.add_attribute(a); schema.set_domain(dom); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write Array array(ctx, array_uri, TILEDB_WRITE); @@ -1333,7 +1334,7 @@ TEST_CASE( auto a = Attribute::create(ctx, "a"); schema.add_attribute(a); schema.set_domain(dom); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write Array array(ctx, array_uri, TILEDB_WRITE); @@ -1465,7 +1466,7 @@ TEST_CASE( schema.set_tile_order(TILEDB_COL_MAJOR); schema.set_cell_order(TILEDB_COL_MAJOR); schema.set_domain(dom); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write Array array(ctx, array_uri, TILEDB_WRITE); @@ -1526,7 +1527,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_SPARSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::vector data_w = {1}; @@ -1573,7 +1574,7 @@ TEST_CASE( schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); schema.set_allows_dups(true); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::vector data_w = {1}; @@ -1619,7 +1620,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::vector data_w = { @@ -1667,7 +1668,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_uri, schema); + Array::create(ctx, array_uri, schema); // Write std::vector data_w = { @@ -1720,7 +1721,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_SPARSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); // Write std::vector data_w = {1}; @@ -1771,7 +1772,7 @@ TEST_CASE( ArraySchema schema(ctx, TILEDB_DENSE); schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); schema.add_attribute(Attribute::create(ctx, "a")); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); // Try writing on a non-process-global Context Context ctx_non_global; @@ -1844,7 +1845,7 @@ TEST_CASE( schema.set_domain(domain).set_order({{TILEDB_ROW_MAJOR, TILEDB_ROW_MAJOR}}); Attribute attr = Attribute::create(ctx, "a"); schema.add_attribute(attr); - Array::create(array_name, schema); + Array::create(ctx, array_name, schema); REQUIRE(vfs.ls(array_name).size() == 1); // Ensure the array can be opened and write to it @@ -2039,7 +2040,7 @@ TEST_CASE("C++ API: Read empty array", "[cppapi][read-empty-array]") { schema.set_domain(domain); schema.add_attribute(Attribute::create(ctx, "a")); schema.set_allows_dups(dups); - Array::create(array_name_1d, schema); + Array::create(ctx, array_name_1d, schema); Array array(ctx, array_name_1d, TILEDB_READ); std::vector d(1);