Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: Array schema resource management. #4652

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/src/unit-ReadCellSlabIter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void ReadCellSlabIterFx::create_result_space_tiles(
}

void set_result_tile_dim(
const ArraySchema& array_schema,
const ArraySchema<ContextResources::resource_manager_type>& array_schema,
ResultTile& result_tile,
std::string dim,
uint64_t dim_idx,
Expand Down
4 changes: 2 additions & 2 deletions test/src/unit-filter-pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ TEST_CASE("Filter: Test compression", "[filter][compression]") {
CHECK(dim->set_domain(dim_dom).ok());
auto domain{make_shared<tiledb::sm::Domain>(HERE())};
CHECK(domain->add_dimension(dim).ok());
tiledb::sm::ArraySchema schema;
tiledb::sm::ArraySchema<ContextResources::resource_manager_type> schema;
tiledb::sm::Attribute attr("attr", Datatype::UINT64);
CHECK(schema.add_attribute(make_shared<tiledb::sm::Attribute>(HERE(), attr))
.ok());
Expand Down Expand Up @@ -526,7 +526,7 @@ TEST_CASE("Filter: Test compression var", "[filter][compression][var]") {
CHECK(dim->set_domain(dim_dom).ok());
auto domain{make_shared<tiledb::sm::Domain>(HERE())};
CHECK(domain->add_dimension(dim).ok());
tiledb::sm::ArraySchema schema;
tiledb::sm::ArraySchema<ContextResources::resource_manager_type> schema;
tiledb::sm::Attribute attr("attr", Datatype::UINT64);
CHECK(schema.add_attribute(make_shared<tiledb::sm::Attribute>(HERE(), attr))
.ok());
Expand Down
4 changes: 2 additions & 2 deletions test/src/unit-request-handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct HandleLoadArraySchemaRequestFx : RequestHandlerFx {
}

virtual shared_ptr<ArraySchema> create_schema() override;
ArraySchema call_handler(
ArraySchema<ContextResources::resource_manager_type> call_handler(
serialization::LoadArraySchemaRequest req, SerializationType stype);

shared_ptr<const Enumeration> create_string_enumeration(
Expand Down Expand Up @@ -414,7 +414,7 @@ shared_ptr<ArraySchema> HandleLoadArraySchemaRequestFx::create_schema() {
return schema;
}

ArraySchema HandleLoadArraySchemaRequestFx::call_handler(
ArraySchema<ContextResources::resource_manager_type> HandleLoadArraySchemaRequestFx::call_handler(
serialization::LoadArraySchemaRequest req, SerializationType stype) {
// If this looks weird, its because we're using the public C++ API to create
// these objets instead of the internal APIs elsewhere in this test suite.
Expand Down
8 changes: 4 additions & 4 deletions test/src/unit-tile-metadata-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ TEMPLATE_LIST_TEST_CASE(

// Generate the array schema.
uint64_t num_cells = empty_tile ? 0 : 1000;
ArraySchema schema;
ArraySchema<ContextResources::resource_manager_type> schema;
schema.set_capacity(num_cells);
Attribute a("a", tiledb_type);
a.set_cell_val_num(cell_val_num);
Expand Down Expand Up @@ -256,7 +256,7 @@ TEMPLATE_LIST_TEST_CASE(
auto type = tiledb::impl::type_to_tiledb<T>();

// Generate the array schema.
ArraySchema schema;
ArraySchema<ContextResources::resource_manager_type> schema;
schema.set_capacity(4);
Attribute a("a", (Datatype)type.tiledb_type);
CHECK(schema.add_attribute(make_shared<Attribute>(HERE(), a)).ok());
Expand Down Expand Up @@ -331,7 +331,7 @@ TEST_CASE(

// Generate the array schema.
uint64_t num_cells = empty_tile ? 0 : 20;
ArraySchema schema;
ArraySchema<ContextResources::resource_manager_type> schema;
schema.set_capacity(num_cells);
Attribute a("a", Datatype::STRING_ASCII);
a.set_cell_val_num(constants::var_num);
Expand Down Expand Up @@ -431,7 +431,7 @@ TEST_CASE(
"TileMetadataGenerator: var data tiles same string, different lengths",
"[tile-metadata-generator][var-data][same-length]") {
// Generate the array schema.
ArraySchema schema;
ArraySchema<ContextResources::resource_manager_type> schema;
schema.set_capacity(2);
Attribute a("a", Datatype::CHAR);
a.set_cell_val_num(constants::var_num);
Expand Down
6 changes: 4 additions & 2 deletions tiledb/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
*/
#include "common-std.h"

namespace tiledb::common {}
namespace tiledb::common {
using context_bypass_RM = void;
}
namespace tdb = tiledb::common;

/*
Expand Down Expand Up @@ -74,4 +76,4 @@ constexpr bool is_experimental_build = true;
constexpr bool is_experimental_build = false;
#endif // TILEDB_EXPERIMENTAL_FEATURES

#endif // TILEDB_COMMON_COMMON_H
#endif // TILEDB_COMMON_COMMON_H
14 changes: 7 additions & 7 deletions tiledb/sm/array/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ bool Array::is_remote() const {
return remote_;
}

tuple<Status, optional<shared_ptr<ArraySchema>>> Array::get_array_schema()
tuple<Status, optional<shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>> Array::get_array_schema()
const {
// Error if the array is not open
if (!is_open_)
Expand Down Expand Up @@ -1238,8 +1238,8 @@ std::unordered_map<std::string, uint64_t> Array::get_average_var_cell_sizes()
/* ********************************* */

tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>,
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>,
std::vector<shared_ptr<FragmentMetadata>>>
Array::open_for_reads() {
auto timer_se = resources_.stats().start_timer(
Expand All @@ -1254,8 +1254,8 @@ Array::open_for_reads() {
}

tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>
Array::open_for_reads_without_fragments() {
auto timer_se = resources_.stats().start_timer(
"array_open_read_without_fragments_load_schemas");
Expand All @@ -1271,8 +1271,8 @@ Array::open_for_reads_without_fragments() {

tuple<
Status,
optional<shared_ptr<ArraySchema>>,
optional<std::unordered_map<std::string, shared_ptr<ArraySchema>>>>
optional<shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>,
optional<std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>>
Array::open_for_writes() {
auto timer_se =
resources_.stats().start_timer("array_open_write_load_schemas");
Expand Down
42 changes: 22 additions & 20 deletions tiledb/sm/array/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ using namespace tiledb::common;
namespace tiledb {
namespace sm {

class ArraySchema;
template <>
class ArraySchema<ContextResources::resource_manager_type>;

class SchemaEvolution;
class FragmentMetadata;
enum class QueryType : uint8_t;
Expand Down Expand Up @@ -122,30 +124,30 @@ class OpenedArray {
}

/** Returns the latest array schema. */
inline const ArraySchema& array_schema_latest() const {
inline const ArraySchema<ContextResources::resource_manager_type>& array_schema_latest() const {
return *(array_schema_latest_.get());
}

/** Returns the latest array schema as a shared pointer. */
inline shared_ptr<ArraySchema> array_schema_latest_ptr() const {
inline shared_ptr<ArraySchema<ContextResources::resource_manager_type>> array_schema_latest_ptr() const {
return array_schema_latest_;
}

/** Sets the latest array schema. */
inline void set_array_schema_latest(
const shared_ptr<ArraySchema>& array_schema) {
const shared_ptr<ArraySchema<ContextResources::resource_manager_type>>& array_schema) {
array_schema_latest_ = array_schema;
}

/** Returns all array schemas. */
inline const std::unordered_map<std::string, shared_ptr<ArraySchema>>&
inline const std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>&
array_schemas_all() const {
return array_schemas_all_;
}

/** Sets all array schema. */
inline void set_array_schemas_all(
std::unordered_map<std::string, shared_ptr<ArraySchema>>&& all_schemas) {
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>&& all_schemas) {
array_schemas_all_ = std::move(all_schemas);
}

Expand Down Expand Up @@ -211,12 +213,12 @@ class OpenedArray {
optional<ArrayDirectory> array_dir_;

/** The latest array schema. */
shared_ptr<ArraySchema> array_schema_latest_;
shared_ptr<ArraySchema<ContextResources::resource_manager_type>> array_schema_latest_;

/**
* A map of all array_schemas_all
*/
std::unordered_map<std::string, shared_ptr<ArraySchema>> array_schemas_all_;
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>> array_schemas_all_;

/** The array metadata. */
Metadata metadata_;
Expand Down Expand Up @@ -316,22 +318,22 @@ class Array {
* @param array_schema The array schema to set.
*/
inline void set_array_schema_latest(
const shared_ptr<ArraySchema>& array_schema) {
const shared_ptr<ArraySchema<ContextResources::resource_manager_type>>& array_schema) {
opened_array_->set_array_schema_latest(array_schema);
}

/** Returns the latest array schema. */
inline const ArraySchema& array_schema_latest() const {
inline const ArraySchema<ContextResources::resource_manager_type>& array_schema_latest() const {
return opened_array_->array_schema_latest();
}

/** Returns the latest array schema as a shared pointer. */
inline shared_ptr<const ArraySchema> array_schema_latest_ptr() const {
inline shared_ptr<const ArraySchema<ContextResources::resource_manager_type>> array_schema_latest_ptr() const {
return opened_array_->array_schema_latest_ptr();
}

/** Returns array schemas map. */
inline const std::unordered_map<std::string, shared_ptr<ArraySchema>>&
inline const std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>&
array_schemas_all() const {
return opened_array_->array_schemas_all();
}
Expand All @@ -341,7 +343,7 @@ class Array {
* @param all_schemas The array schemas to set.
*/
inline void set_array_schemas_all(
std::unordered_map<std::string, shared_ptr<ArraySchema>>&& all_schemas) {
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>&& all_schemas) {
opened_array_->set_array_schemas_all(std::move(all_schemas));
}

Expand Down Expand Up @@ -509,7 +511,7 @@ class Array {
bool is_remote() const;

/** Retrieves the array schema. Errors if the array is not open. */
tuple<Status, optional<shared_ptr<ArraySchema>>> get_array_schema() const;
tuple<Status, optional<shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>> get_array_schema() const;

/** Retrieves the query type. Throws if the array is not open. */
QueryType get_query_type() const;
Expand Down Expand Up @@ -960,8 +962,8 @@ class Array {
* after the array is opened.
*/
tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>,
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>,
std::vector<shared_ptr<FragmentMetadata>>>
open_for_reads();

Expand All @@ -975,8 +977,8 @@ class Array {
* ArraySchemaMap Map of all array schemas found keyed by name
*/
tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>
open_for_reads_without_fragments();

/** Opens an array for writes.
Expand All @@ -990,8 +992,8 @@ class Array {
*/
tuple<
Status,
optional<shared_ptr<ArraySchema>>,
optional<std::unordered_map<std::string, shared_ptr<ArraySchema>>>>
optional<shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>,
optional<std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>>
open_for_writes();

/** Clears the cached max buffer sizes and subarray. */
Expand Down
18 changes: 9 additions & 9 deletions tiledb/sm/array/array_directory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ArrayDirectory::ArrayDirectory(
/* API */
/* ********************************* */

shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_from_uri(
shared_ptr<ArraySchema<ContextResources::resource_manager_type>> ArrayDirectory::load_array_schema_from_uri(
ContextResources& resources,
const URI& schema_uri,
const EncryptionKey& encryption_key) {
Expand All @@ -101,11 +101,11 @@ shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_from_uri(

// Deserialize
Deserializer deserializer(tile.data(), tile.size());
return make_shared<ArraySchema>(
HERE(), ArraySchema::deserialize(deserializer, schema_uri));
return make_shared<ArraySchema<ContextResources::resource_manager_type>>(
HERE(), ArraySchema<ContextResources::resource_manager_type>::deserialize(deserializer, schema_uri));
}

shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_latest(
shared_ptr<ArraySchema<ContextResources::resource_manager_type>> ArrayDirectory::load_array_schema_latest(
const EncryptionKey& encryption_key) const {
auto timer_se =
resources_.get().stats().start_timer("sm_load_array_schema_latest");
Expand All @@ -126,8 +126,8 @@ shared_ptr<ArraySchema> ArrayDirectory::load_array_schema_latest(
}

tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>
ArrayDirectory::load_array_schemas(const EncryptionKey& encryption_key) const {
// Load all array schemas
auto&& array_schemas = load_all_array_schemas(encryption_key);
Expand All @@ -141,7 +141,7 @@ ArrayDirectory::load_array_schemas(const EncryptionKey& encryption_key) const {
return {it->second, array_schemas};
}

std::unordered_map<std::string, shared_ptr<ArraySchema>>
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>
ArrayDirectory::load_all_array_schemas(
const EncryptionKey& encryption_key) const {
auto timer_se =
Expand All @@ -158,7 +158,7 @@ ArrayDirectory::load_all_array_schemas(
"Cannot get the array schema vector; No array schemas found.");
}

std::vector<shared_ptr<ArraySchema>> schema_vector;
std::vector<shared_ptr<ArraySchema<ContextResources::resource_manager_type>>> schema_vector;
auto schema_num = schema_uris.size();
schema_vector.resize(schema_num);

Expand All @@ -178,7 +178,7 @@ ArrayDirectory::load_all_array_schemas(
});
throw_if_not_ok(status);

std::unordered_map<std::string, shared_ptr<ArraySchema>> array_schemas;
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>> array_schemas;
for (const auto& schema : schema_vector) {
array_schemas[schema->name()] = schema;
}
Expand Down
12 changes: 6 additions & 6 deletions tiledb/sm/array/array_directory.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class ArrayDirectory {
* @param encryption_key The encryption key to use.
* @return Status, the loaded array schema
*/
static shared_ptr<ArraySchema> load_array_schema_from_uri(
static shared_ptr<ArraySchema<ContextResources::resource_manager_type>> load_array_schema_from_uri(
ContextResources& resources,
const URI& array_schema_uri,
const EncryptionKey& encryption_key);
Expand All @@ -353,7 +353,7 @@ class ArrayDirectory {
* @param encryption_key The encryption key to use.
* @return Status, a new ArraySchema
*/
shared_ptr<ArraySchema> load_array_schema_latest(
shared_ptr<ArraySchema<ContextResources::resource_manager_type>> load_array_schema_latest(
const EncryptionKey& encryption_key) const;

/**
Expand All @@ -365,12 +365,12 @@ class ArrayDirectory {
* @param encryption_key The encryption key to use.
* @return tuple of Status, latest array schema and all array schemas.
* Status Ok on success, else error
* ArraySchema The latest array schema.
* ArraySchema<ContextResources::resource_manager_type> The latest array schema.
* ArraySchemaMap Map of all array schemas loaded, keyed by name
*/
tuple<
shared_ptr<ArraySchema>,
std::unordered_map<std::string, shared_ptr<ArraySchema>>>
shared_ptr<ArraySchema<ContextResources::resource_manager_type>>,
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>>
load_array_schemas(const EncryptionKey& encryption_key) const;

/**
Expand All @@ -382,7 +382,7 @@ class ArrayDirectory {
* Status Ok on success, else error
* ArraySchemaMap Map of all array schemas found keyed by name
*/
std::unordered_map<std::string, shared_ptr<ArraySchema>>
std::unordered_map<std::string, shared_ptr<ArraySchema<ContextResources::resource_manager_type>>>
load_all_array_schemas(const EncryptionKey& encryption_key) const;

/**
Expand Down
Loading
Loading