Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 committed Mar 29, 2024
1 parent 52d3295 commit cd74399
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/src/unit-capi-fragment_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ TEST_CASE(
"- Unconsolidated metadata num: 1\n" + "- To vacuum num: 0\n" +
"- Fragment #1:\n" + " > URI: " + written_frag_uri + "\n" +
" > Type: sparse\n" + " > Non-empty domain: [a, ddd]\n" +
" > Size: 3442\n" + " > Cell num: 4\n" +
" > Size: 3460\n" + " > Cell num: 4\n" +
" > Timestamp range: [1, 1]\n" + " > Format version: " + ver + "\n" +
" > Has consolidated metadata: no\n";
FILE* gold_fout = fopen("gold_fout.txt", "w");
Expand Down
3 changes: 3 additions & 0 deletions tiledb/sm/array/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,9 @@ NDRange& Array::shape_data() {
for (const auto& meta : frag_meta) {
// Check each dimension in the fragment shape data.
const auto& frag_shape_data = meta->shape_data();
if (meta->has_shape_data()) {
opened_array_->has_shape_data() = true;
}
for (size_t j = 0; j < frag_shape_data.size(); j++) {
auto dim = opened_array_->array_schema_latest().dimension_ptr(j);
if (dim->var_size()) {
Expand Down
13 changes: 13 additions & 0 deletions tiledb/sm/array/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class OpenedArray {
, metadata_(memory_tracker)
, metadata_loaded_(false)
, non_empty_domain_computed_(false)
, has_shape_data_(false)
, encryption_key_(make_shared<EncryptionKey>(HERE()))
, timestamp_start_(timestamp_start)
, timestamp_end_opened_at_(timestamp_end_opened_at)
Expand Down Expand Up @@ -170,6 +171,10 @@ class OpenedArray {
return non_empty_domain_;
}

inline bool& has_shape_data() {
return has_shape_data_;
}

/** Gets a reference to the shape data. */
inline NDRange& shape_data() {
return shape_data_;
Expand Down Expand Up @@ -236,6 +241,9 @@ class OpenedArray {
/** The non-empty domain of the array. */
NDRange non_empty_domain_;

/** True if the opened array has shape data, else false. */
bool has_shape_data_;

/** The shape data for the array. */
NDRange shape_data_;

Expand Down Expand Up @@ -784,6 +792,11 @@ class Array {
opened_array_->non_empty_domain_computed() = is_computed;
}

/** Returns a reference to has_shape_data_ */
inline bool has_shape_data() const {
return opened_array_->has_shape_data();
}

/** Returns a reference to the shape data. */
NDRange& shape_data();

Expand Down
9 changes: 6 additions & 3 deletions tiledb/sm/consolidator/fragment_consolidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,13 @@ Status FragmentConsolidator::create_queries(
(*query_w)->set_processed_conditions(processed_conditions);

auto shape_data = array_for_reads->shape_data();
for (size_t i = 0; i < shape_data.size(); i++) {
(*query_w)->set_shape(
i, shape_data[i].start_fixed(), shape_data[i].end_fixed());
if (array_for_reads->has_shape_data()) {
for (size_t i = 0; i < shape_data.size(); i++) {
(*query_w)->set_shape(
i, shape_data[i].start_fixed(), shape_data[i].end_fixed());
}
}

// Set the URI for the new fragment.
auto frag_uri =
array_for_reads->array_directory().get_fragments_dir(write_version);
Expand Down
16 changes: 9 additions & 7 deletions tiledb/sm/fragment/fragment_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ FragmentMetadata::FragmentMetadata(
, last_tile_cell_num_(0)
, has_timestamps_(has_timestamps)
, has_delete_meta_(has_deletes_meta)
, has_shape_data_(false)
, sparse_tile_num_(0)
, meta_file_size_(0)
, rtree_(RTree(
Expand Down Expand Up @@ -164,6 +165,7 @@ void FragmentMetadata::set_shape_data(const NDRange& range) {
" dimensions on a fragment with " +
std::to_string(array_schema_->dim_num()) + " dimensions.");
}
has_shape_data_ = true;
shape_data_ = range;
}

Expand Down Expand Up @@ -2805,12 +2807,12 @@ void FragmentMetadata::load_mbrs(Deserializer& deserializer) {
}

void FragmentMetadata::load_non_empty_domain(Deserializer& deserializer) {
// Get null non-empty domain
if (version_ <= 2) {
load_non_empty_domain_v1_v2(deserializer);
return;
}

// Get null non-empty domain.
bool null_non_empty_domain = load_null_non_empty_domain(deserializer);
if (!null_non_empty_domain) {
if (version_ == 3 || version_ == 4) {
Expand All @@ -2835,10 +2837,11 @@ bool FragmentMetadata::load_null_non_empty_domain(
// has_shape_data (char)
// shape_data: range(void*)
void FragmentMetadata::load_shape_data(Deserializer& deserializer) {
bool has_shape_data = deserializer.read<char>();
if (!has_shape_data) {
has_shape_data_ = deserializer.read<char>();
if (!has_shape_data_) {
// Load the non-empty domain if there is no shape data.
load_non_empty_domain(deserializer);
load_non_empty_domain_v5_or_higher(deserializer);
shape_data_ = non_empty_domain_;
} else {
auto dim_num = array_schema_->dim_num();
shape_data_.reserve(dim_num);
Expand Down Expand Up @@ -3985,13 +3988,12 @@ void FragmentMetadata::write_non_empty_domain(Serializer& serializer) const {
// shape_data: range(void*)
void FragmentMetadata::write_shape_data(Serializer& serializer) const {
// Write has shape data.
auto has_shape_data = (char)!shape_data_.empty();
serializer.write<char>(has_shape_data);
serializer.write<char>((char)has_shape_data_);

auto& domain = array_schema_->domain();
auto dim_num = domain.dim_num();
// If the shape data is empty, write the non-empty domain.
if (shape_data_.empty()) {
if (!has_shape_data_) {
write_non_empty_domain(serializer);
} else {
// Write shape data for each dimension.
Expand Down
7 changes: 7 additions & 0 deletions tiledb/sm/fragment/fragment_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,10 @@ class FragmentMetadata {
return non_empty_domain_;
}

bool& has_shape_data() {
return has_shape_data_;
}

/** Shape data accessor. */
NDRange& shape_data() {
return shape_data_;
Expand Down Expand Up @@ -1350,6 +1354,9 @@ class FragmentMetadata {
/** True if the fragment has delete metadata, and false otherwise. */
bool has_delete_meta_;

/** True if the fragment has shape data, false otherwise. */
bool has_shape_data_;

/** Number of sparse tiles. */
uint64_t sparse_tile_num_;

Expand Down

0 comments on commit cd74399

Please sign in to comment.