diff --git a/test/src/unit-Reader.cc b/test/src/unit-Reader.cc index 4f17aa0013d..6b053017984 100644 --- a/test/src/unit-Reader.cc +++ b/test/src/unit-Reader.cc @@ -248,7 +248,7 @@ TEST_CASE_METHOD( auto d2{make_shared(HERE(), "d2", Datatype::INT32, tracker_)}; CHECK(d2->set_domain(&domain_vec[2]).ok()); CHECK(d2->set_tile_extent(&tile_extents_vec[1]).ok()); - auto dom{make_shared(HERE())}; + auto dom{make_shared(HERE(), tracker_)}; CHECK(dom->add_dimension(d1).ok()); CHECK(dom->add_dimension(d2).ok()); diff --git a/test/src/unit-capi-array.cc b/test/src/unit-capi-array.cc index 60f5907ce51..123212deb8d 100644 --- a/test/src/unit-capi-array.cc +++ b/test/src/unit-capi-array.cc @@ -79,6 +79,9 @@ using namespace tiledb::common; using namespace tiledb::sm; struct ArrayFx { + // The memory tracker + shared_ptr memory_tracker_; + // TileDB context tiledb_ctx_t* ctx_; tiledb_vfs_t* vfs_; @@ -116,7 +119,8 @@ static const std::string test_ca_file = std::string(TILEDB_TEST_INPUTS_DIR) + "/test_certs/public.crt"; ArrayFx::ArrayFx() - : fs_vec_(vfs_test_get_fs_vec()) { + : memory_tracker_(tiledb::test::create_test_memory_tracker()) + , fs_vec_(vfs_test_get_fs_vec()) { // Initialize vfs test REQUIRE(vfs_test_init(fs_vec_, &ctx_, &vfs_).ok()); } @@ -2586,13 +2590,12 @@ TEST_CASE_METHOD( 1, &buff); REQUIRE(rc == TILEDB_OK); - auto memory_tracker = ctx_->resources().create_memory_tracker(); auto st = tiledb::sm::serialization::array_deserialize( array->array_.get(), tiledb::sm::SerializationType::CAPNP, buff->buffer(), ctx_->storage_manager(), - memory_tracker); + memory_tracker_); REQUIRE(st.ok()); // 6. Server: Close array and clean up diff --git a/test/src/unit-cppapi-schema-evolution.cc b/test/src/unit-cppapi-schema-evolution.cc index 0ce1c1921b5..83a64f6e33e 100644 --- a/test/src/unit-cppapi-schema-evolution.cc +++ b/test/src/unit-cppapi-schema-evolution.cc @@ -821,7 +821,8 @@ TEST_CASE( int range[2] = {0, 1000}; throw_if_not_ok(dim->set_domain(range)); - auto dom = make_shared(HERE()); + auto dom = make_shared( + HERE(), tiledb::test::get_test_memory_tracker()); throw_if_not_ok(dom->add_dimension(dim)); throw_if_not_ok(schema->set_domain(dom)); diff --git a/test/src/unit-enumerations.cc b/test/src/unit-enumerations.cc index 15d874c31fa..b96bb5a9806 100644 --- a/test/src/unit-enumerations.cc +++ b/test/src/unit-enumerations.cc @@ -141,11 +141,11 @@ struct EnumerationFx { void rm_array(); + shared_ptr memory_tracker_; URI uri_; Config cfg_; Context ctx_; EncryptionKey enc_key_; - shared_ptr memory_tracker_; }; template @@ -2554,9 +2554,9 @@ struct TypeParams { }; EnumerationFx::EnumerationFx() - : uri_("enumeration_test_array") - , ctx_(cfg_) - , memory_tracker_(tiledb::test::create_test_memory_tracker()) { + : memory_tracker_(tiledb::test::create_test_memory_tracker()) + , uri_("enumeration_test_array") + , ctx_(cfg_) { rm_array(); throw_if_not_ok(enc_key_.set_key(EncryptionType::NO_ENCRYPTION, nullptr, 0)); memory_tracker_ = tiledb::test::create_test_memory_tracker(); @@ -2850,7 +2850,7 @@ shared_ptr EnumerationFx::create_schema() { int range[2] = {0, 1000}; throw_if_not_ok(dim->set_domain(range)); - auto dom = make_shared(HERE()); + auto dom = make_shared(HERE(), memory_tracker_); throw_if_not_ok(dom->add_dimension(dim)); throw_if_not_ok(schema->set_domain(dom)); diff --git a/test/src/unit-request-handlers.cc b/test/src/unit-request-handlers.cc index f55f7923166..8585cf1a9a6 100644 --- a/test/src/unit-request-handlers.cc +++ b/test/src/unit-request-handlers.cc @@ -62,6 +62,7 @@ struct RequestHandlerFx { shared_ptr get_array(QueryType type); + shared_ptr memory_tracker_; URI uri_; Config cfg_; Context ctx_; @@ -96,16 +97,13 @@ struct HandleConsolidationPlanRequestFx : RequestHandlerFx { } virtual shared_ptr create_schema() override { - auto schema = make_shared( - HERE(), ArrayType::SPARSE, tiledb::test::create_test_memory_tracker()); + auto schema = + make_shared(HERE(), ArrayType::SPARSE, memory_tracker_); auto dim = make_shared( - HERE(), - "dim1", - Datatype::INT32, - tiledb::test::get_test_memory_tracker()); + HERE(), "dim1", Datatype::INT32, memory_tracker_); int range[2] = {0, 1000}; throw_if_not_ok(dim->set_domain(range)); - auto dom = make_shared(HERE()); + auto dom = make_shared(HERE(), memory_tracker_); throw_if_not_ok(dom->add_dimension(dim)); throw_if_not_ok(schema->set_domain(dom)); return schema; @@ -340,7 +338,8 @@ TEST_CASE_METHOD( /* ********************************* */ RequestHandlerFx::RequestHandlerFx(const std::string uri) - : uri_(uri) + : memory_tracker_(tiledb::test::create_test_memory_tracker()) + , uri_(uri) , ctx_(cfg_) { delete_array(); throw_if_not_ok(enc_key_.set_key(EncryptionType::NO_ENCRYPTION, nullptr, 0)); @@ -402,14 +401,14 @@ HandleLoadArraySchemaRequestFx::create_string_enumeration( shared_ptr HandleLoadArraySchemaRequestFx::create_schema() { // Create a schema to serialize - auto schema = make_shared( - HERE(), ArrayType::SPARSE, tiledb::test::create_test_memory_tracker()); - auto dim = make_shared( - HERE(), "dim1", Datatype::INT32, tiledb::test::get_test_memory_tracker()); + auto schema = + make_shared(HERE(), ArrayType::SPARSE, memory_tracker_); + auto dim = + make_shared(HERE(), "dim1", Datatype::INT32, memory_tracker_); int range[2] = {0, 1000}; throw_if_not_ok(dim->set_domain(range)); - auto dom = make_shared(HERE()); + auto dom = make_shared(HERE(), memory_tracker_); throw_if_not_ok(dom->add_dimension(dim)); throw_if_not_ok(schema->set_domain(dom)); @@ -445,15 +444,13 @@ shared_ptr HandleLoadArraySchemaRequestFx::call_handler( resp_buf); REQUIRE(rval == TILEDB_OK); - auto memory_tracker = - ctx.ptr()->context().resources().create_memory_tracker(); return serialization::deserialize_load_array_schema_response( - stype, resp_buf->buffer(), memory_tracker); + stype, resp_buf->buffer(), memory_tracker_); } shared_ptr HandleQueryPlanRequestFx::create_schema() { - auto schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker_); schema->set_capacity(10000); throw_if_not_ok(schema->set_cell_order(Layout::ROW_MAJOR)); throw_if_not_ok(schema->set_tile_order(Layout::ROW_MAJOR)); @@ -466,7 +463,7 @@ shared_ptr HandleQueryPlanRequestFx::create_schema() { HERE(), "dim2", Datatype::INT32, tiledb::test::get_test_memory_tracker()); throw_if_not_ok(dim2->set_domain(&dim_domain[2])); - auto dom = make_shared(HERE()); + auto dom = make_shared(HERE(), memory_tracker_); throw_if_not_ok(dom->add_dimension(dim1)); throw_if_not_ok(dom->add_dimension(dim2)); throw_if_not_ok(schema->set_domain(dom)); diff --git a/tiledb/api/c_api/domain/domain_api.cc b/tiledb/api/c_api/domain/domain_api.cc index 3a694a97c11..00238c143fc 100644 --- a/tiledb/api/c_api/domain/domain_api.cc +++ b/tiledb/api/c_api/domain/domain_api.cc @@ -30,12 +30,16 @@ #include "../dimension/dimension_api_internal.h" #include "domain_api_external.h" #include "domain_api_internal.h" +#include "tiledb/common/memory_tracker.h" namespace tiledb::api { -int32_t tiledb_domain_alloc(tiledb_domain_handle_t** domain) { +int32_t tiledb_domain_alloc( + tiledb_ctx_t* ctx, tiledb_domain_handle_t** domain) { ensure_output_pointer_is_valid(domain); - *domain = tiledb_domain_handle_t::make_handle(); + auto memory_tracker = ctx->resources().create_memory_tracker(); + memory_tracker->set_type(tiledb::sm::MemoryTrackerType::ARRAY_CREATE); + *domain = tiledb_domain_handle_t::make_handle(memory_tracker); return TILEDB_OK; } @@ -147,7 +151,8 @@ int32_t tiledb_domain_dump(const tiledb_domain_t* domain, FILE* out) { using tiledb::api::api_entry_context; CAPI_INTERFACE(domain_alloc, tiledb_ctx_t* ctx, tiledb_domain_t** domain) { - return api_entry_context(ctx, domain); + return tiledb::api::api_entry_with_context( + ctx, domain); } CAPI_INTERFACE_VOID(domain_free, tiledb_domain_t** domain) { diff --git a/tiledb/api/c_api/domain/domain_api_internal.h b/tiledb/api/c_api/domain/domain_api_internal.h index 76a427ce8ac..dabd36e402c 100644 --- a/tiledb/api/c_api/domain/domain_api_internal.h +++ b/tiledb/api/c_api/domain/domain_api_internal.h @@ -35,6 +35,10 @@ #include "tiledb/api/c_api_support/handle/handle.h" #include "tiledb/sm/array_schema/domain.h" +namespace tiledb::sm { +class MemoryTracker; +} + struct tiledb_domain_handle_t : public tiledb::api::CAPIHandle { private: @@ -54,8 +58,9 @@ struct tiledb_domain_handle_t * `class Domain` is principally a container for `Dimension` objects. Domain * handles are first constructed as empty containers. */ - tiledb_domain_handle_t() - : domain_{make_shared(HERE())} { + explicit tiledb_domain_handle_t( + shared_ptr memory_tracker) + : domain_{make_shared(HERE(), memory_tracker)} { } /** diff --git a/tiledb/api/c_api/domain/test/compile_capi_domain_stub_main.cc b/tiledb/api/c_api/domain/test/compile_capi_domain_stub_main.cc index c5959eecd7b..6b6a726109e 100644 --- a/tiledb/api/c_api/domain/test/compile_capi_domain_stub_main.cc +++ b/tiledb/api/c_api/domain/test/compile_capi_domain_stub_main.cc @@ -29,7 +29,6 @@ #include "../domain_api_internal.h" int main() { - // Domain is easy to deal with because it has a default constructor. - tiledb_domain_handle_t x{}; + tiledb_domain_handle_t x{shared_ptr()}; return 0; } diff --git a/tiledb/common/memory_tracker.cc b/tiledb/common/memory_tracker.cc index b7b24e17cde..344e8410633 100644 --- a/tiledb/common/memory_tracker.cc +++ b/tiledb/common/memory_tracker.cc @@ -76,6 +76,8 @@ std::string memory_type_to_str(MemoryType type) { return "DimensionLabels"; case MemoryType::DIMENSIONS: return "Dimensions"; + case MemoryType::DOMAINS: + return "Domains"; case MemoryType::TILE_SUMS: return "TileSums"; case MemoryType::TILE_WRITER_DATA: diff --git a/tiledb/common/memory_tracker.h b/tiledb/common/memory_tracker.h index 8858fe07210..4a9525a4a90 100644 --- a/tiledb/common/memory_tracker.h +++ b/tiledb/common/memory_tracker.h @@ -115,6 +115,7 @@ enum class MemoryType { DIMENSION_LABELS, DIMENSIONS, METADATA, + DOMAINS, TILE_SUMS, TILE_WRITER_DATA }; diff --git a/tiledb/sm/array/test/unit_consistency.h b/tiledb/sm/array/test/unit_consistency.h index 20e5c310f8f..c0b56da2e64 100644 --- a/tiledb/sm/array/test/unit_consistency.h +++ b/tiledb/sm/array/test/unit_consistency.h @@ -40,6 +40,7 @@ #include "../array.h" #include "../consistency.h" +#include "test/support/src/mem_helpers.h" #include "tiledb/sm/array_schema/dimension.h" #include "tiledb/sm/enums/array_type.h" #include "tiledb/sm/enums/encryption_type.h" @@ -108,8 +109,8 @@ class WhiteboxConsistencyController : public ConsistencyController { throw_if_not_ok(dim->set_tile_extent(&tile_extent)); std::vector> dims = {dim}; - shared_ptr domain = - make_shared(HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR); + shared_ptr domain = make_shared( + HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR, memory_tracker_); // Create the ArraySchema shared_ptr schema = make_shared( diff --git a/tiledb/sm/array_schema/array_schema.h b/tiledb/sm/array_schema/array_schema.h index b2e91fc31ed..8c360db4307 100644 --- a/tiledb/sm/array_schema/array_schema.h +++ b/tiledb/sm/array_schema/array_schema.h @@ -476,6 +476,7 @@ class ArraySchema { * * @param deserializer The deserializer to deserialize from. * @param uri The uri of the Array. + * @param memory_tracker The memory tracker to use. * @return A new ArraySchema. */ static shared_ptr deserialize( diff --git a/tiledb/sm/array_schema/dimension_label.cc b/tiledb/sm/array_schema/dimension_label.cc index 06dbf28c202..b9138099dd8 100644 --- a/tiledb/sm/array_schema/dimension_label.cc +++ b/tiledb/sm/array_schema/dimension_label.cc @@ -28,6 +28,7 @@ #include "tiledb/sm/array_schema/dimension_label.h" #include "tiledb/common/common.h" +#include "tiledb/common/memory_tracker.h" #include "tiledb/sm/array_schema/array_schema.h" #include "tiledb/sm/array_schema/dimension.h" #include "tiledb/sm/array_schema/domain.h" @@ -176,7 +177,11 @@ DimensionLabel::DimensionLabel( throw_if_not_ok( index_dims.back()->set_tile_extent(dim->tile_extent().data())); throw_if_not_ok(schema_->set_domain(make_shared( - HERE(), Layout::ROW_MAJOR, index_dims, Layout::ROW_MAJOR))); + HERE(), + Layout::ROW_MAJOR, + index_dims, + Layout::ROW_MAJOR, + memory_tracker))); // Create and set dimension label attribute. auto label_attr = make_shared( diff --git a/tiledb/sm/array_schema/domain.cc b/tiledb/sm/array_schema/domain.cc index 877774a184e..1b5883458b7 100644 --- a/tiledb/sm/array_schema/domain.cc +++ b/tiledb/sm/array_schema/domain.cc @@ -37,6 +37,7 @@ #include "tiledb/common/blank.h" #include "tiledb/common/heap_memory.h" #include "tiledb/common/logger.h" +#include "tiledb/common/memory_tracker.h" #include "tiledb/sm/enums/datatype.h" #include "tiledb/sm/enums/layout.h" #include "tiledb/sm/misc/tdb_math.h" @@ -58,7 +59,13 @@ namespace tiledb::sm { /* CONSTRUCTORS & DESTRUCTORS */ /* ********************************* */ -Domain::Domain() { +Domain::Domain(shared_ptr memory_tracker) + : memory_tracker_(memory_tracker) + , dimensions_(memory_tracker_->get_resource(MemoryType::DIMENSIONS)) + , dimension_ptrs_(memory_tracker_->get_resource(MemoryType::DIMENSIONS)) + , cell_order_cmp_func_(memory_tracker_->get_resource(MemoryType::DOMAINS)) + , cell_order_cmp_func_2_(memory_tracker_->get_resource(MemoryType::DOMAINS)) + , tile_order_cmp_func_(memory_tracker_->get_resource(MemoryType::DOMAINS)) { cell_order_ = Layout::ROW_MAJOR; tile_order_ = Layout::ROW_MAJOR; dim_num_ = 0; @@ -68,11 +75,20 @@ Domain::Domain() { Domain::Domain( Layout cell_order, const std::vector> dimensions, - Layout tile_order) - : cell_order_(cell_order) - , dimensions_(dimensions) + Layout tile_order, + shared_ptr memory_tracker) + : memory_tracker_(memory_tracker) + , cell_order_(cell_order) + , dimensions_( + dimensions.begin(), + dimensions.end(), + memory_tracker_->get_resource(MemoryType::DIMENSIONS)) + , dimension_ptrs_(memory_tracker_->get_resource(MemoryType::DIMENSIONS)) , dim_num_(static_cast(dimensions.size())) - , tile_order_(tile_order) { + , tile_order_(tile_order) + , cell_order_cmp_func_(memory_tracker_->get_resource(MemoryType::DOMAINS)) + , cell_order_cmp_func_2_(memory_tracker_->get_resource(MemoryType::DOMAINS)) + , tile_order_cmp_func_(memory_tracker_->get_resource(MemoryType::DOMAINS)) { /* * Verify that the input vector has no non-null elements in order to meet the * class invariant. Initialize the dimensions mirror. @@ -93,32 +109,6 @@ Domain::Domain( set_tile_cell_order_cmp_funcs(); } -Domain::Domain(Domain&& rhs) - : cell_num_per_tile_(rhs.cell_num_per_tile_) - , cell_order_(rhs.cell_order_) - , dimensions_(move(rhs.dimensions_)) - , dimension_ptrs_(move(rhs.dimension_ptrs_)) - , dim_num_(rhs.dim_num_) - , tile_order_(rhs.tile_order_) - , cell_order_cmp_func_(move(rhs.cell_order_cmp_func_)) - , cell_order_cmp_func_2_(move(rhs.cell_order_cmp_func_2_)) - , tile_order_cmp_func_(move(rhs.tile_order_cmp_func_)) { -} - -Domain& Domain::operator=(Domain&& rhs) { - cell_num_per_tile_ = rhs.cell_num_per_tile_; - cell_order_ = rhs.cell_order_; - dim_num_ = rhs.dim_num_; - cell_order_cmp_func_ = move(rhs.cell_order_cmp_func_); - tile_order_cmp_func_ = move(rhs.tile_order_cmp_func_); - dimensions_ = move(rhs.dimensions_); - dimension_ptrs_ = move(rhs.dimension_ptrs_); - tile_order_ = rhs.tile_order_; - cell_order_cmp_func_2_ = move(rhs.cell_order_cmp_func_2_); - - return *this; -} - /* ********************************* */ /* API */ /* ********************************* */ @@ -352,7 +342,7 @@ shared_ptr Domain::deserialize( } return tiledb::common::make_shared( - HERE(), cell_order, dimensions, tile_order); + HERE(), cell_order, dimensions, tile_order, memory_tracker); } const Range& Domain::domain(unsigned i) const { @@ -610,8 +600,9 @@ const ByteVecValue& Domain::tile_extent(unsigned i) const { std::vector Domain::tile_extents() const { std::vector ret(dim_num_); - for (unsigned d = 0; d < dim_num_; ++d) + for (unsigned d = 0; d < dim_num_; ++d) { ret[d] = tile_extent(d); + } return ret; } diff --git a/tiledb/sm/array_schema/domain.h b/tiledb/sm/array_schema/domain.h index c8007c8d2aa..5544169cb44 100644 --- a/tiledb/sm/array_schema/domain.h +++ b/tiledb/sm/array_schema/domain.h @@ -35,6 +35,7 @@ #include "tiledb/common/common.h" #include "tiledb/common/macros.h" +#include "tiledb/common/pmr.h" #include "tiledb/common/status.h" #include "tiledb/common/types/dynamic_typed_datum.h" #include "tiledb/common/types/untyped_datum.h" @@ -75,20 +76,18 @@ class Domain { /* CONSTRUCTORS & DESTRUCTORS */ /* ********************************* */ - /** Empty constructor. */ - Domain(); + /** Deleted default constructor */ + Domain() = delete; + + /** Constructor. */ + Domain(shared_ptr memory_tracker); /** Constructor.*/ Domain( Layout cell_order, const std::vector> dimensions, - Layout tile_order); - - /** Copy constructor. */ - Domain(const Domain&) = default; - - /** Move constructor. */ - Domain(Domain&& rhs); + Layout tile_order, + shared_ptr memory_tracker); /** Destructor. */ ~Domain() = default; @@ -97,11 +96,8 @@ class Domain { /* OPERATORS */ /* ********************************* */ - /** Copy-assignment operator. */ - DISABLE_COPY_ASSIGN(Domain); - - /** Move-assignment operator. */ - Domain& operator=(Domain&& rhs); + DISABLE_COPY_AND_COPY_ASSIGN(Domain); + DISABLE_MOVE_AND_MOVE_ASSIGN(Domain); /* ********************************* */ /* API */ @@ -508,6 +504,9 @@ class Domain { /* PRIVATE ATTRIBUTES */ /* ********************************* */ + /** The memory tracker for this Domain. */ + shared_ptr memory_tracker_; + /** The number of cells per tile. Meaningful only for the **dense** case. */ uint64_t cell_num_per_tile_; @@ -523,7 +522,7 @@ class Domain { * * @invariant All pointers in the vector are non-null. */ - std::vector> dimensions_; + tdb::pmr::vector> dimensions_; /** * Non-allocating mirror of the dimensions vector. @@ -535,7 +534,7 @@ class Domain { * * @invariant All pointers in the vector are non-null. */ - std::vector dimension_ptrs_; + tdb::pmr::vector dimension_ptrs_; /** The number of dimensions. */ unsigned dim_num_; @@ -551,7 +550,7 @@ class Domain { * - buff: The buffer that stores all coorinates; * - a, b: The positions of the two coordinates in the buffer to compare. */ - std::vector cell_order_cmp_func_; @@ -561,7 +560,7 @@ class Domain { * * - coord_a, coord_b: The two coordinates to compare. */ - std::vector + tdb::pmr::vector cell_order_cmp_func_2_; /** @@ -571,7 +570,7 @@ class Domain { * - dim: The dimension to compare on. * - coord_a, coord_b: The two coordinates to compare. */ - std::vector tile_order_cmp_func_; diff --git a/tiledb/sm/array_schema/test/array_schema_test_support.h b/tiledb/sm/array_schema/test/array_schema_test_support.h index 84f2e09ef53..2c751fe1bfd 100644 --- a/tiledb/sm/array_schema/test/array_schema_test_support.h +++ b/tiledb/sm/array_schema/test/array_schema_test_support.h @@ -239,6 +239,8 @@ class TestAttribute { * Array Schema wrapper */ class TestArraySchema { + shared_ptr memory_tracker_; + ArraySchema schema_; /** @@ -263,9 +265,14 @@ class TestArraySchema { static shared_ptr make_domain( std::initializer_list dimensions, Layout cell_order, - Layout tile_order) { + Layout tile_order, + shared_ptr memory_tracker) { return make_shared( - HERE(), cell_order, make_dimension_vector(dimensions), tile_order); + HERE(), + cell_order, + make_dimension_vector(dimensions), + tile_order, + memory_tracker); } /** @@ -307,7 +314,11 @@ class TestArraySchema { "", // name array_type, false, // allow duplicates - make_domain(dimensions, cell_order, tile_order), + make_domain( + dimensions, + cell_order, + tile_order, + tiledb::test::create_test_memory_tracker()), cell_order, tile_order, 10000, // capacity diff --git a/tiledb/sm/array_schema/test/unit_domain_data.cc b/tiledb/sm/array_schema/test/unit_domain_data.cc index 6997ca9cf23..b26174acefa 100644 --- a/tiledb/sm/array_schema/test/unit_domain_data.cc +++ b/tiledb/sm/array_schema/test/unit_domain_data.cc @@ -111,7 +111,8 @@ struct TestNullInitializer { }; TEST_CASE("DomainTypedDataView::DomainTypedDataView, null initializer") { - Domain d{}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + Domain d{memory_tracker}; // tiledb::sm::Dimension dim{"", tiledb::sm::Datatype::INT32}; auto dim{make_shared( HERE(), @@ -136,7 +137,8 @@ TEST_CASE("DomainTypedDataView::DomainTypedDataView, simple initializer") { } }; - Domain d{}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + Domain d{memory_tracker}; auto dim{make_shared( HERE(), "", diff --git a/tiledb/sm/array_schema/test/unit_tile_domain.cc b/tiledb/sm/array_schema/test/unit_tile_domain.cc index 771c2772687..95676b33898 100644 --- a/tiledb/sm/array_schema/test/unit_tile_domain.cc +++ b/tiledb/sm/array_schema/test/unit_tile_domain.cc @@ -31,12 +31,14 @@ */ #include +#include "src/mem_helpers.h" #include "tiledb/sm/array_schema/tile_domain.h" using namespace tiledb::sm; TEST_CASE("TileDomain: Test 1D", "[TileDomain][1d]") { int32_t tile_extent_v = 10; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(1); tile_extents[0].assign_as(tile_extent_v); Layout layout = Layout::ROW_MAJOR; @@ -72,6 +74,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 1, 10}; std::vector domain_slice = {1, 10, 1, 10}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -115,6 +118,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 1, 10}; std::vector domain_slice = {4, 10, 2, 8}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -153,6 +157,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 1, 10}; std::vector domain_slice = {1, 10, 1, 10}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -191,6 +196,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 1, 10}; std::vector domain_slice = {4, 10, 2, 8}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -228,6 +234,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 11, 20}; std::vector domain_slice = {4, 10, 12, 18}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -260,6 +267,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 11, 20}; std::vector domain_slice = {2, 10, 12, 18}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -297,6 +305,7 @@ TEST_CASE( std::vector domain_vec = {1, 10, 11, 20}; std::vector domain_slice = {2, 10, 12, 18}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); @@ -323,6 +332,7 @@ TEST_CASE("TileDomain: Test 2D, covers", "[TileDomain][2d][covers]") { std::vector domain_slice_1 = {2, 6, 2, 8}; std::vector domain_slice_2 = {3, 6, 1, 7}; std::vector tile_extents_vec = {2, 5}; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::vector tile_extents(2); tile_extents[0].assign_as(tile_extents_vec[0]); tile_extents[1].assign_as(tile_extents_vec[1]); diff --git a/tiledb/sm/array_schema/tile_domain.h b/tiledb/sm/array_schema/tile_domain.h index a89e498e9af..1cc96404a23 100644 --- a/tiledb/sm/array_schema/tile_domain.h +++ b/tiledb/sm/array_schema/tile_domain.h @@ -36,6 +36,7 @@ #include #include +#include "tiledb/common/pmr.h" #include "tiledb/sm/array_schema/dimension.h" #include "tiledb/sm/enums/layout.h" #include "tiledb/sm/misc/types.h" @@ -81,13 +82,13 @@ class TileDomain { unsigned id, const NDRange& domain, const NDRange& domain_slice, - const std::vector tile_extents, + const std::vector& tile_extents, Layout layout) : id_(id) , dim_num_((unsigned)domain.size()) , domain_(domain) , domain_slice_(domain_slice) - , tile_extents_(tile_extents) + , tile_extents_(tile_extents.begin(), tile_extents.end()) , layout_(layout) { assert(layout == Layout::ROW_MAJOR || layout == Layout::COL_MAJOR); compute_tile_domain(domain, domain_slice, tile_extents); diff --git a/tiledb/sm/c_api/tiledb_filestore.cc b/tiledb/sm/c_api/tiledb_filestore.cc index 482ccde4e2e..f8c933659e0 100644 --- a/tiledb/sm/c_api/tiledb_filestore.cc +++ b/tiledb/sm/c_api/tiledb_filestore.cc @@ -142,7 +142,7 @@ int32_t tiledb_filestore_schema_create( tiledb::sm::ByteVecValue(std::move(tile_extent_vec)), memory_tracker); - auto domain = make_shared(HERE()); + auto domain = make_shared(HERE(), memory_tracker); throw_if_not_ok(domain->add_dimension(dim)); auto attr = make_shared( diff --git a/tiledb/sm/consolidator/test/unit_fragment_consolidator.cc b/tiledb/sm/consolidator/test/unit_fragment_consolidator.cc index f6f222324c0..b5e728fff26 100644 --- a/tiledb/sm/consolidator/test/unit_fragment_consolidator.cc +++ b/tiledb/sm/consolidator/test/unit_fragment_consolidator.cc @@ -53,7 +53,8 @@ shared_ptr make_schema( tiledb::test::create_test_memory_tracker()); // Create the domain/dimensions. - Domain domain; + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + auto domain{make_shared(HERE(), memory_tracker)}; for (uint64_t d = 0; d < dim_types.size(); d++) { auto dim{make_shared( HERE(), @@ -135,9 +136,9 @@ shared_ptr make_schema( } } - REQUIRE(domain.add_dimension(dim).ok()); + REQUIRE(domain->add_dimension(dim).ok()); } - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); // Create the attributes. for (uint64_t a = 0; a < attr_types.size(); a++) { diff --git a/tiledb/sm/filter/webp_filter.h b/tiledb/sm/filter/webp_filter.h index 5842f6351be..cd6648a06cb 100644 --- a/tiledb/sm/filter/webp_filter.h +++ b/tiledb/sm/filter/webp_filter.h @@ -40,6 +40,7 @@ constexpr bool webp_filter_exists = false; #endif // TILEDB_WEBP #include "tiledb/common/common.h" +#include "tiledb/common/pmr.h" #include "tiledb/sm/enums/filter_option.h" #include "tiledb/sm/enums/filter_type.h" #include "tiledb/sm/filter/filter.h" diff --git a/tiledb/sm/fragment/fragment_info.cc b/tiledb/sm/fragment/fragment_info.cc index 0f0f42eae20..e83d42687a2 100644 --- a/tiledb/sm/fragment/fragment_info.cc +++ b/tiledb/sm/fragment/fragment_info.cc @@ -33,6 +33,7 @@ #include "tiledb/sm/fragment/fragment_info.h" #include "tiledb/common/common.h" #include "tiledb/common/logger.h" +#include "tiledb/common/memory_tracker.h" #include "tiledb/sm/array/array.h" #include "tiledb/sm/array/array_directory.h" #include "tiledb/sm/array_schema/dimension.h" diff --git a/tiledb/sm/query/test/unit_query_condition.cc b/tiledb/sm/query/test/unit_query_condition.cc index 70381200638..264aa3f5fb1 100644 --- a/tiledb/sm/query/test/unit_query_condition.cc +++ b/tiledb/sm/query/test/unit_query_condition.cc @@ -1571,8 +1571,9 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { const char* fill_value = "ac"; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::get_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -1583,7 +1584,7 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -1594,15 +1595,15 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -1638,14 +1639,15 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { const T fill_value = 3; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::get_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_cell_val_num(1); attr.set_fill_value(&fill_value, sizeof(T)); REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -1656,15 +1658,15 @@ void test_apply(const Datatype type, bool var_size, bool nullable) { REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -1746,8 +1748,9 @@ TEST_CASE( return; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -1758,7 +1761,7 @@ TEST_CASE( REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -1769,10 +1772,8 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); std::vector> frag_md(1); frag_md[0] = make_shared( @@ -2300,8 +2301,9 @@ void test_apply_dense( const char* fill_value = "ac"; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -2312,7 +2314,7 @@ void test_apply_dense( REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -2323,17 +2325,15 @@ void test_apply_dense( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -2369,14 +2369,15 @@ void test_apply_dense(const Datatype type, bool var_size, bool nullable) { const T fill_value = 3; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_cell_val_num(1); attr.set_fill_value(&fill_value, sizeof(T)); REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -2387,17 +2388,15 @@ void test_apply_dense(const Datatype type, bool var_size, bool nullable) { REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -2480,8 +2479,9 @@ TEST_CASE( return; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -2492,7 +2492,7 @@ TEST_CASE( REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -2503,17 +2503,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -3014,8 +3012,9 @@ void test_apply_sparse( const char* fill_value = "ac"; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -3026,7 +3025,7 @@ void test_apply_sparse( REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -3037,17 +3036,15 @@ void test_apply_sparse( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -3083,14 +3080,15 @@ void test_apply_sparse(const Datatype type, bool var_size, bool nullable) { const T fill_value = 3; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_cell_val_num(1); attr.set_fill_value(&fill_value, sizeof(T)); REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -3101,17 +3099,15 @@ void test_apply_sparse(const Datatype type, bool var_size, bool nullable) { REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -3860,12 +3856,13 @@ TEST_CASE( const Datatype type = Datatype::UINT64; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -3876,17 +3873,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -4150,8 +4145,9 @@ TEST_CASE( const Datatype type = GENERATE(Datatype::STRING_ASCII, Datatype::STRING_UTF8); // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::get_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(false); attr.set_cell_val_num(constants::var_num); @@ -4159,7 +4155,7 @@ TEST_CASE( REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -4170,15 +4166,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -4510,8 +4506,9 @@ TEST_CASE( const Datatype type = Datatype::STRING_UTF8; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(false); attr.set_cell_val_num(constants::var_num); @@ -4519,7 +4516,7 @@ TEST_CASE( REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -4530,15 +4527,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // For pasting into a Python shell: @@ -4838,13 +4835,14 @@ TEST_CASE( const Datatype type = Datatype::FLOAT32; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(true); REQUIRE(array_schema->add_attribute(tdb::make_shared(HERE(), attr)) .ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -4855,17 +4853,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE( - array_schema->set_domain(make_shared(HERE(), domain)) - .ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. @@ -4939,8 +4935,9 @@ TEST_CASE( return; // Initialize the array schema. - shared_ptr array_schema = make_shared( - HERE(), ArrayType::DENSE, tiledb::test::create_test_memory_tracker()); + auto memory_tracker = tiledb::test::create_test_memory_tracker(); + shared_ptr array_schema = + make_shared(HERE(), ArrayType::DENSE, memory_tracker); Attribute attr(field_name, type); attr.set_nullable(nullable); attr.set_cell_val_num(var_size ? constants::var_num : 2); @@ -4951,7 +4948,7 @@ TEST_CASE( REQUIRE( array_schema->add_attribute(make_shared(HERE(), attr)).ok()); - Domain domain; + auto domain{make_shared(HERE(), memory_tracker)}; auto dim{make_shared( HERE(), "dim1", @@ -4962,15 +4959,15 @@ TEST_CASE( REQUIRE(dim->set_domain(range).ok()); uint32_t tile_extent = 10; REQUIRE(dim->set_tile_extent(&tile_extent).ok()); - REQUIRE(domain.add_dimension(dim).ok()); - REQUIRE(array_schema->set_domain(make_shared(HERE(), domain)).ok()); + REQUIRE(domain->add_dimension(dim).ok()); + REQUIRE(array_schema->set_domain(domain).ok()); FragmentMetadata frag_md( nullptr, array_schema, URI(), std::make_pair(0, 0), - tiledb::test::create_test_memory_tracker(), + memory_tracker, true); // Initialize the result tile. diff --git a/tiledb/sm/query_plan/test/unit_query_plan.cc b/tiledb/sm/query_plan/test/unit_query_plan.cc index eefbc92807b..fedbc453a7f 100644 --- a/tiledb/sm/query_plan/test/unit_query_plan.cc +++ b/tiledb/sm/query_plan/test/unit_query_plan.cc @@ -35,6 +35,7 @@ #include #include "../query_plan.h" #include "external/include/nlohmann/json.hpp" +#include "test/support/src/mem_helpers.h" #include "tiledb/sm/array/array.h" #include "tiledb/sm/array_schema/dimension.h" #include "tiledb/sm/enums/array_type.h" @@ -60,6 +61,7 @@ struct QueryPlanFx { URI array_uri(const std::string& uri); shared_ptr memory_tracker_; + TemporaryLocalDirectory temp_dir_; Config cfg_; shared_ptr logger_; @@ -77,8 +79,8 @@ tdb_unique_ptr QueryPlanFx::create_array(const URI uri) { throw_if_not_ok(dim->set_tile_extent(&tile_extent)); std::vector> dims = {dim}; - shared_ptr domain = - make_shared(HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR); + shared_ptr domain = make_shared( + HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR, memory_tracker_); // Create the ArraySchema shared_ptr schema = make_shared( @@ -110,7 +112,7 @@ URI QueryPlanFx::array_uri(const std::string& array_name) { } QueryPlanFx::QueryPlanFx() - : memory_tracker_(tiledb::test::get_test_memory_tracker()) + : memory_tracker_(tiledb::test::create_test_memory_tracker()) , logger_(make_shared(HERE(), "foo")) , resources_(cfg_, logger_, 1, 1, "") , sm_(make_shared(resources_, logger_, cfg_)) { diff --git a/tiledb/sm/rtree/test/unit_rtree.cc b/tiledb/sm/rtree/test/unit_rtree.cc index 5cdfdd7166f..6d81dd0c949 100644 --- a/tiledb/sm/rtree/test/unit_rtree.cc +++ b/tiledb/sm/rtree/test/unit_rtree.cc @@ -90,7 +90,8 @@ Domain create_domain( const std::vector& dim_names, const std::vector& dim_types, const std::vector& dim_domains, - const std::vector& dim_tile_extents) { + const std::vector& dim_tile_extents, + shared_ptr memory_tracker) { assert(!dim_names.empty()); assert(dim_names.size() == dim_types.size()); assert(dim_names.size() == dim_domains.size()); @@ -122,7 +123,8 @@ Domain create_domain( dimensions.emplace_back(std::move(dim)); } - return Domain(Layout::ROW_MAJOR, dimensions, Layout::ROW_MAJOR); + return Domain( + Layout::ROW_MAJOR, dimensions, Layout::ROW_MAJOR, memory_tracker); } TEST_CASE("RTree: Test R-Tree, basic functions", "[rtree][basic]") { @@ -139,10 +141,11 @@ TEST_CASE("RTree: Test R-Tree, basic functions", "[rtree][basic]") { // 1D int32_t dim_dom[] = {1, 1000}; int32_t dim_extent = 10; - Domain dom1 = - create_domain({"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}); + Domain dom1 = create_domain( + {"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}, tracker); + const Domain d1 = create_domain( + {"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}, tracker); auto mbrs_1d = create_mbrs({1, 3, 5, 10, 20, 22}, tracker); - const Domain d1{dom1}; RTree rtree1(&d1, 3, tracker); CHECK(!rtree1.set_leaf(0, mbrs_1d[0]).ok()); CHECK(rtree1.set_leaf_num(mbrs_1d.size()).ok()); @@ -200,10 +203,16 @@ TEST_CASE("RTree: Test R-Tree, basic functions", "[rtree][basic]") { {"d1", "d2"}, {Datatype::INT64, Datatype::INT64}, {dim_dom_2, dim_dom_2}, - {&dim_extent_2, &dim_extent_2}); + {&dim_extent_2, &dim_extent_2}, + tracker); + const Domain d2 = create_domain( + {"d1", "d2"}, + {Datatype::INT64, Datatype::INT64}, + {dim_dom_2, dim_dom_2}, + {&dim_extent_2, &dim_extent_2}, + tracker); auto mbrs_2d = create_mbrs( {1, 3, 5, 10, 20, 22, 24, 25, 11, 15, 30, 31}, tracker); - const Domain d2{dom2}; RTree rtree2(&d2, 5, tracker); CHECK(rtree2.set_leaves(mbrs_2d).ok()); rtree2.build_tree(); @@ -240,9 +249,10 @@ TEST_CASE("RTree: Test R-Tree, basic functions", "[rtree][basic]") { float dim_extent_f = 10.0; auto mbrs_f = create_mbrs({1.0f, 3.0f, 5.0f, 10.0f, 20.0f, 22.0f}, tracker); - Domain dom2f = - create_domain({"d"}, {Datatype::FLOAT32}, {dim_dom_f}, {&dim_extent_f}); - const Domain d2f{dom2f}; + Domain dom2f = create_domain( + {"d"}, {Datatype::FLOAT32}, {dim_dom_f}, {&dim_extent_f}, tracker); + const Domain d2f = create_domain( + {"d"}, {Datatype::FLOAT32}, {dim_dom_f}, {&dim_extent_f}, tracker); RTree rtreef(&d2f, 5, tracker); CHECK(rtreef.set_leaves(mbrs_f).ok()); rtreef.build_tree(); @@ -283,11 +293,10 @@ TEST_CASE("RTree: Test 1D R-tree, height 2", "[rtree][1d][2h]") { std::vector is_default(1, false); int32_t dim_dom[] = {1, 1000}; int32_t dim_extent = 10; - Domain dom1 = - create_domain({"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}); + Domain dom1 = create_domain( + {"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}, tracker); auto mbrs = create_mbrs({1, 3, 5, 10, 20, 22}, tracker); - const Domain d1{dom1}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); @@ -332,10 +341,9 @@ TEST_CASE("RTree: Test 1D R-tree, height 3", "[rtree][1d][3h]") { int32_t dim_extent = 10; auto mbrs = create_mbrs( {1, 3, 5, 10, 20, 22, 30, 35, 36, 38, 40, 49, 50, 51, 65, 69}, tracker); - Domain dom1 = - create_domain({"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}); - const Domain d1(dom1); - RTree rtree(&d1, 3, tracker); + Domain dom1 = create_domain( + {"d"}, {Datatype::INT32}, {dim_dom}, {&dim_extent}, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 3); @@ -397,15 +405,15 @@ TEST_CASE("RTree: Test 2D R-tree, height 2", "[rtree][2d][2h]") { std::vector is_default(2, false); int32_t dim_dom[] = {1, 1000}; int32_t dim_extent = 10; - Domain dom2 = create_domain( + Domain dom1 = create_domain( {"d1", "d2"}, {Datatype::INT32, Datatype::INT32}, {dim_dom, dim_dom}, - {&dim_extent, &dim_extent}); + {&dim_extent, &dim_extent}, + tracker); auto mbrs = create_mbrs( {1, 3, 2, 4, 5, 7, 6, 9, 10, 12, 10, 15}, tracker); - const Domain d2{dom2}; - RTree rtree(&d2, 3, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); @@ -451,17 +459,17 @@ TEST_CASE("RTree: Test 2D R-tree, height 3", "[rtree][2d][3h]") { std::vector is_default(2, false); int32_t dim_dom[] = {1, 1000}; int32_t dim_extent = 10; - Domain dom2 = create_domain( + Domain dom1 = create_domain( {"d1", "d2"}, {Datatype::INT32, Datatype::INT32}, {dim_dom, dim_dom}, - {&dim_extent, &dim_extent}); + {&dim_extent, &dim_extent}, + tracker); auto mbrs = create_mbrs( {1, 3, 2, 4, 5, 7, 6, 9, 10, 12, 10, 15, 11, 15, 20, 22, 16, 16, 23, 23, 19, 20, 24, 26, 25, 28, 30, 32, 30, 35, 35, 37, 40, 42, 40, 42}, tracker); - const Domain d2{dom2}; - RTree rtree(&d2, 3, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 3); @@ -532,14 +540,20 @@ TEST_CASE( int32_t int32_dom[] = {5, 10}; uint8_t uint8_extent = 2; int32_t int32_extent = 2; - Domain dom = create_domain( + Domain dom1 = create_domain( + {"d1", "d2"}, + {Datatype::UINT8, Datatype::INT32}, + {uint8_dom, int32_dom}, + {&uint8_extent, &int32_extent}, + tracker); + const Domain d1 = create_domain( {"d1", "d2"}, {Datatype::UINT8, Datatype::INT32}, {uint8_dom, int32_dom}, - {&uint8_extent, &int32_extent}); + {&uint8_extent, &int32_extent}, + tracker); auto mbrs = create_mbrs({0, 1, 3, 5}, {5, 6, 7, 9}, tracker); - const Domain d1{dom}; RTree rtree(&d1, 5, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); @@ -555,7 +569,7 @@ TEST_CASE( int32_t int32_r_no[] = {1, 10}; range_no[0] = Range(uint8_r_no, sizeof(uint8_r_no)); range_no[1] = Range(int32_r_no, sizeof(int32_r_no)); - double ratio = dom.overlap_ratio(range_no, is_default, mbrs[0]); + double ratio = dom1.overlap_ratio(range_no, is_default, mbrs[0]); CHECK(ratio == 0.0); // Check full domain overlap @@ -564,9 +578,9 @@ TEST_CASE( int32_t int32_r_full[] = {1, 10}; range_full[0] = Range(uint8_r_full, sizeof(uint8_r_full)); range_full[1] = Range(int32_r_full, sizeof(int32_r_full)); - ratio = dom.overlap_ratio(range_full, is_default, mbrs[0]); + ratio = dom1.overlap_ratio(range_full, is_default, mbrs[0]); CHECK(ratio == 1.0); - ratio = dom.overlap_ratio(range_full, is_default, mbrs[1]); + ratio = dom1.overlap_ratio(range_full, is_default, mbrs[1]); CHECK(ratio == 1.0); // Check partial domain overlap @@ -575,7 +589,7 @@ TEST_CASE( int32_t int32_r_part[] = {5, 5}; range_part[0] = Range(uint8_r_part, sizeof(uint8_r_part)); range_part[1] = Range(int32_r_part, sizeof(int32_r_part)); - ratio = dom.overlap_ratio(range_part, is_default, mbrs[0]); + ratio = dom1.overlap_ratio(range_part, is_default, mbrs[0]); CHECK(ratio == 0.25); } @@ -589,14 +603,20 @@ TEST_CASE( float float_dom[] = {0.1f, 0.9f}; uint64_t uint64_extent = 2; float float_extent = 0.1f; - Domain dom = create_domain( + Domain dom1 = create_domain( {"d1", "d2"}, {Datatype::UINT64, Datatype::FLOAT32}, {uint64_dom, float_dom}, - {&uint64_extent, &float_extent}); + {&uint64_extent, &float_extent}, + tracker); + const Domain d1 = create_domain( + {"d1", "d2"}, + {Datatype::UINT64, Datatype::FLOAT32}, + {uint64_dom, float_dom}, + {&uint64_extent, &float_extent}, + tracker); auto mbrs = create_mbrs({0, 1, 3, 5}, {.5f, .6f, .7f, .9f}, tracker); - const Domain d1{dom}; RTree rtree(&d1, 5, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); @@ -612,7 +632,7 @@ TEST_CASE( float float_r_no[] = {.1f, .9f}; range_no[0] = Range(uint64_r_no, sizeof(uint64_r_no)); range_no[1] = Range(float_r_no, sizeof(float_r_no)); - double ratio = dom.overlap_ratio(range_no, is_default, mbrs[0]); + double ratio = dom1.overlap_ratio(range_no, is_default, mbrs[0]); CHECK(ratio == 0.0); // Check full domain overlap @@ -621,9 +641,9 @@ TEST_CASE( float float_r_full[] = {.1f, 1.0f}; range_full[0] = Range(uint64_r_full, sizeof(uint64_r_full)); range_full[1] = Range(float_r_full, sizeof(float_r_full)); - ratio = dom.overlap_ratio(range_full, is_default, mbrs[0]); + ratio = dom1.overlap_ratio(range_full, is_default, mbrs[0]); CHECK(ratio == 1.0); - ratio = dom.overlap_ratio(range_full, is_default, mbrs[1]); + ratio = dom1.overlap_ratio(range_full, is_default, mbrs[1]); CHECK(ratio == 1.0); // Check partial domain overlap @@ -632,7 +652,7 @@ TEST_CASE( float float_r_part[] = {.5f, .55f}; range_part[0] = Range(uint64_r_part, sizeof(uint64_r_part)); range_part[1] = Range(float_r_part, sizeof(float_r_part)); - ratio = dom.overlap_ratio(range_part, is_default, mbrs[0]); + ratio = dom1.overlap_ratio(range_part, is_default, mbrs[0]); CHECK(ratio == 0.25); } @@ -650,11 +670,11 @@ TEST_CASE( {"d1", "d2"}, {Datatype::UINT8, Datatype::INT32}, {uint8_dom, int32_dom}, - {&uint8_extent, &int32_extent}); + {&uint8_extent, &int32_extent}, + tracker); auto mbrs = create_mbrs( {0, 1, 3, 5, 11, 20}, {5, 6, 7, 9, 11, 30}, tracker); - const Domain d1{dom}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); @@ -720,11 +740,11 @@ TEST_CASE( {"d1", "d2"}, {Datatype::UINT8, Datatype::INT32}, {uint8_dom, int32_dom}, - {&uint8_extent, &int32_extent}); + {&uint8_extent, &int32_extent}, + tracker); auto mbrs = create_mbrs( {0, 1, 3, 5, 11, 20, 21, 26}, {5, 6, 7, 9, 11, 30, 31, 40}, tracker); - const Domain d1{dom}; - RTree rtree(&d1, 2, tracker); + RTree rtree(&dom, 2, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 3); @@ -856,13 +876,12 @@ TEST_CASE( // Build tree auto tracker = create_test_memory_tracker(); std::vector is_default(1, false); - Domain dom1 = - create_domain({"d"}, {Datatype::STRING_ASCII}, {nullptr}, {nullptr}); + Domain dom1 = create_domain( + {"d"}, {Datatype::STRING_ASCII}, {nullptr}, {nullptr}, tracker); auto mbrs = create_str_mbrs<1>({"aa", "b", "eee", "g", "gggg", "ii"}, tracker); - const Domain d1{dom1}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); @@ -935,8 +954,8 @@ TEST_CASE( // Build tree auto tracker = create_test_memory_tracker(); std::vector is_default(1, false); - Domain dom1 = - create_domain({"d"}, {Datatype::STRING_ASCII}, {nullptr}, {nullptr}); + Domain dom1 = create_domain( + {"d"}, {Datatype::STRING_ASCII}, {nullptr}, {nullptr}, tracker); auto mbrs = create_str_mbrs<1>( {"aa", "b", @@ -952,8 +971,7 @@ TEST_CASE( "oop"}, tracker); - const Domain d1{dom1}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom1, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 3); @@ -1033,13 +1051,13 @@ TEST_CASE( {"d1", "d2"}, {Datatype::STRING_ASCII, Datatype::STRING_ASCII}, {nullptr, nullptr}, - {nullptr, nullptr}); + {nullptr, nullptr}, + tracker); auto mbrs = create_str_mbrs<2>( {"aa", "b", "eee", "g", "gggg", "ii", "jj", "lll", "m", "n", "oo", "qqq"}, tracker); - const Domain d1{dom}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); @@ -1136,17 +1154,17 @@ TEST_CASE( std::vector is_default(2, false); int32_t dom_int32[] = {1, 20}; int32_t tile_extent = 5; + auto tracker = create_test_memory_tracker(); Domain dom = create_domain( {"d1", "d2"}, {Datatype::STRING_ASCII, Datatype::INT32}, {nullptr, dom_int32}, - {nullptr, &tile_extent}); - auto tracker = create_test_memory_tracker(); + {nullptr, &tile_extent}, + tracker); auto mbrs = create_str_int32_mbrs( {"aa", "b", "eee", "g", "gggg", "ii"}, {1, 5, 7, 8, 10, 14}, tracker); - const Domain d1{dom}; - RTree rtree(&d1, 3, tracker); + RTree rtree(&dom, 3, tracker); CHECK(rtree.set_leaves(mbrs).ok()); rtree.build_tree(); CHECK(rtree.height() == 2); diff --git a/tiledb/sm/serialization/array.h b/tiledb/sm/serialization/array.h index a08b531b1e9..e048510c534 100644 --- a/tiledb/sm/serialization/array.h +++ b/tiledb/sm/serialization/array.h @@ -72,6 +72,7 @@ Status array_to_capnp( * @param storage_manager the storage manager associated with the array * @param array Array to deserialize into * @param client_side Allows to specify different behavior depending on who is + * @param memory_tracker Memory tracker to use for memory allocations. * serializing, the client (1) or the Cloud server (0). This is sometimes needed * since they are both using the same Core library APIs for serialization. * @param memory_tracker Memory tracker to use on the deserialized object. diff --git a/tiledb/sm/serialization/array_schema.cc b/tiledb/sm/serialization/array_schema.cc index 125d998d6a3..5f3bc76d3a7 100644 --- a/tiledb/sm/serialization/array_schema.cc +++ b/tiledb/sm/serialization/array_schema.cc @@ -750,7 +750,8 @@ shared_ptr domain_from_capnp( dims.emplace_back(dimension_from_capnp(dimension, memory_tracker)); } - return make_shared(HERE(), cell_order, dims, tile_order); + return make_shared( + HERE(), cell_order, dims, tile_order, memory_tracker); } void dimension_label_to_capnp( diff --git a/tiledb/sm/serialization/array_schema.h b/tiledb/sm/serialization/array_schema.h index 2c7fe090440..14b51d7b620 100644 --- a/tiledb/sm/serialization/array_schema.h +++ b/tiledb/sm/serialization/array_schema.h @@ -110,6 +110,7 @@ Status array_schema_to_capnp( * * @param schema_reader Cap'n proto object * @param uri A URI object + * @param memory_tracker The memory tracker to use. * @return a new ArraySchema */ shared_ptr array_schema_from_capnp( @@ -133,6 +134,7 @@ void dimension_label_to_capnp( * Deserialize a dimension label from a cap'n proto object * * @param reader Cap'n proto reader object. + * @param memory_tracker The memory tracker to use. * @return A new DimensionLabel. */ shared_ptr dimension_label_from_capnp( diff --git a/tiledb/sm/serialization/fragment_info.h b/tiledb/sm/serialization/fragment_info.h index 42375f05d66..968a13d38a8 100644 --- a/tiledb/sm/serialization/fragment_info.h +++ b/tiledb/sm/serialization/fragment_info.h @@ -59,6 +59,7 @@ namespace serialization { * @param fragment_info_reader cap'n proto class. * @param uri array uri that the fragment belongs to * @param fragment_info fragment info object to deserialize into. + * @param memory_tracker The memory tracker to use. * @return Status */ Status fragment_info_from_capnp( @@ -125,6 +126,7 @@ Status fragment_info_serialize( * @param serialize_type format the data is serialized in: Cap'n Proto of JSON. * @param uri array uri that the fragment belongs to * @param serialized_buffer buffer to read serialized bytes from. + * @param memory_tracker The memory tracker to use. * @return Status */ Status fragment_info_deserialize( diff --git a/tiledb/sm/serialization/query.h b/tiledb/sm/serialization/query.h index 568faacf0f0..a5ad85c0348 100644 --- a/tiledb/sm/serialization/query.h +++ b/tiledb/sm/serialization/query.h @@ -137,6 +137,7 @@ using CopyState = * @param serialized_buffer Buffer containing serialized query * @param serialize_type Serialization type of serialized query * @param array Array object to deserialize into + * @param memory_tracker Memory tracker to use for allocations. */ Status array_from_query_deserialize( const Buffer& serialized_buffer, diff --git a/tiledb/sm/serialization/test/CMakeLists.txt b/tiledb/sm/serialization/test/CMakeLists.txt index 23edbc74937..832eaae79a9 100644 --- a/tiledb/sm/serialization/test/CMakeLists.txt +++ b/tiledb/sm/serialization/test/CMakeLists.txt @@ -36,7 +36,7 @@ conclude(unit_test) commence(unit_test capnp_array_schema) this_target_sources(main.cc unit_capnp_array_schema.cc) - this_target_link_libraries(TILEDB_CORE_OBJECTS TILEDB_CORE_OBJECTS_ILIB) + this_target_link_libraries(TILEDB_CORE_OBJECTS TILEDB_CORE_OBJECTS_ILIB tiledb_test_support_lib) # Enable serialization target_compile_definitions(unit_capnp_array_schema PRIVATE -DTILEDB_SERIALIZATION) diff --git a/tiledb/sm/serialization/test/unit_capnp_array_schema.cc b/tiledb/sm/serialization/test/unit_capnp_array_schema.cc index ccb4bfa5238..0bd703210f4 100644 --- a/tiledb/sm/serialization/test/unit_capnp_array_schema.cc +++ b/tiledb/sm/serialization/test/unit_capnp_array_schema.cc @@ -112,7 +112,11 @@ TEST_CASE( st = dims[0]->set_domain(&domain1[0]); REQUIRE(st.ok()); st = schema->set_domain(make_shared( - HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR)); + HERE(), + Layout::ROW_MAJOR, + dims, + Layout::ROW_MAJOR, + tiledb::test::get_test_memory_tracker())); REQUIRE(st.ok()); st = schema->add_attribute( make_shared(HERE(), "label", Datatype::FLOAT64)); @@ -158,7 +162,7 @@ TEST_CASE( tiledb::sm::serialization::dimension_label_to_capnp( *dim_label.get(), &builder, true); auto dim_label_clone = tiledb::sm::serialization::dimension_label_from_capnp( - builder, tiledb::test::create_test_memory_tracker()); + builder, tiledb::test::get_test_memory_tracker()); // Check dimension label properties and components. CHECK(dim_label->has_schema() == dim_label_clone->has_schema()); diff --git a/tiledb/sm/storage_manager/storage_manager.cc b/tiledb/sm/storage_manager/storage_manager.cc index 4886c2c22b4..984a7720a62 100644 --- a/tiledb/sm/storage_manager/storage_manager.cc +++ b/tiledb/sm/storage_manager/storage_manager.cc @@ -41,6 +41,7 @@ #include "tiledb/common/heap_memory.h" #include "tiledb/common/logger.h" #include "tiledb/common/memory.h" +#include "tiledb/common/memory_tracker.h" #include "tiledb/common/stdx_string.h" #include "tiledb/sm/array/array.h" #include "tiledb/sm/array/array_directory.h" diff --git a/tiledb/sm/subarray/test/unit_add_ranges_list.cc b/tiledb/sm/subarray/test/unit_add_ranges_list.cc index 06f757721d8..040c7a129d0 100644 --- a/tiledb/sm/subarray/test/unit_add_ranges_list.cc +++ b/tiledb/sm/subarray/test/unit_add_ranges_list.cc @@ -53,6 +53,7 @@ using namespace tiledb::type; TEST_CASE("Subarray::add_ranges_list", "[subarray]") { // Setup an Array needed to construct the Subarray for testing // add_ranges_list. + auto memory_tracker = tiledb::test::create_test_memory_tracker(); std::shared_ptr sp_dim1 = make_shared( HERE(), @@ -68,7 +69,7 @@ TEST_CASE("Subarray::add_ranges_list", "[subarray]") { uint64_t tile_extents[] = {2, 2}; std::vector> dims{sp_dim1, sp_dim2}; std::shared_ptr sp_dom = make_shared( - HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR); + HERE(), Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR, memory_tracker); uint64_t local_DIM_DOMAIN[4] = {1, 12, 1, 12}; CHECK(sp_dim1->set_domain(&local_DIM_DOMAIN[0]).ok()); CHECK(sp_dim2->set_domain(&local_DIM_DOMAIN[2]).ok()); @@ -76,7 +77,8 @@ TEST_CASE("Subarray::add_ranges_list", "[subarray]") { CHECK(sp_dim2->set_tile_extent(&tile_extents[1]).ok()); std::shared_ptr sp_attrib = make_shared(HERE(), "a1", Datatype::INT32); - tiledb::sm::Domain dom{Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR}; + tiledb::sm::Domain dom{ + Layout::ROW_MAJOR, dims, Layout::ROW_MAJOR, memory_tracker}; std::shared_ptr sp_as = make_shared( HERE(),