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

Dense consolidation: set correct non-empty domain. #3635

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -1883,7 +1883,7 @@ TEST_CASE(
"- To vacuum URIs:\n" + " > " + written_frag_uri_1 + "\n > " +
written_frag_uri_2 + "\n > " + written_frag_uri_3 + "\n" +
"- Fragment #1:\n" + " > URI: " + uri + "\n" + " > Type: dense\n" +
" > Non-empty domain: [1, 10]\n" + " > Size: 3208\n" +
" > Non-empty domain: [1, 6]\n" + " > Size: 3208\n" +
" > Cell num: 10\n" + " > Timestamp range: [1, 3]\n" +
" > Format version: " + ver + "\n" +
" > Has consolidated metadata: no\n";
Expand Down
11 changes: 6 additions & 5 deletions tiledb/sm/consolidator/fragment_consolidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ Status FragmentConsolidator::consolidate_fragments(
count++;
domain.expand_ndrange(
frag_info.non_empty_domain(), &union_non_empty_domains);
domain.expand_to_tiles(&union_non_empty_domains);
to_consolidate.emplace_back(frag_info.uri(), frag_info.timestamp_range());
}
}
Expand Down Expand Up @@ -590,9 +589,12 @@ Status FragmentConsolidator::create_queries(
*query_r = tdb_new(Query, storage_manager_, array_for_reads);
RETURN_NOT_OK((*query_r)->set_layout(Layout::GLOBAL_ORDER));

// Refactored reader optimizes for no subarray.
if (!config_.use_refactored_reader_ || dense) {
RETURN_NOT_OK((*query_r)->set_subarray_unsafe(subarray));
// Dense consolidation will do a tile aligned read.
if (dense) {
NDRange read_subarray = subarray;
auto& domain{array_for_reads->array_schema_latest().domain()};
domain.expand_to_tiles(&read_subarray);
RETURN_NOT_OK((*query_r)->set_subarray_unsafe(read_subarray));
}

// Enable consolidation with timestamps on the reader, if applicable.
Expand Down Expand Up @@ -701,7 +703,6 @@ Status FragmentConsolidator::compute_next_to_consolidate(
m_union[i][j] = m_union[i - 1][j];
domain.expand_ndrange(
fragments[i + j].non_empty_domain(), &m_union[i][j]);
domain.expand_to_tiles(&m_union[i][j]);
if (!sparse && !are_consolidatable(
domain, fragment_info, j, j + i, m_union[i][j])) {
// Mark this entry as invalid
Expand Down
15 changes: 13 additions & 2 deletions tiledb/sm/query/writers/global_order_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,19 @@ Status GlobalOrderWriter::finalize_global_write_state() {

// Check if the total number of cells written is equal to the subarray size
if (!coords_info_.has_coords_) { // This implies a dense array
auto expected_cell_num =
array_schema_.domain().cell_num(subarray_.ndrange(0));
auto& domain{array_schema_.domain()};
auto expected_cell_num = domain.cell_num(subarray_.ndrange(0));

// When running the writer for consolidation, we use the expanded domain
// to read and write full tiles, but the subarray here will only contain
// the non-empty domain that doesn't include the extra cells with fill
// values.
if (disable_checks_consolidation_) {
auto expanded_subarray = subarray_.ndrange(0);
domain.expand_to_tiles(&expanded_subarray);
expected_cell_num = domain.cell_num(expanded_subarray);
}

if (cell_num != expected_cell_num) {
std::stringstream ss;
ss << "Failed to finalize global write state; Number "
Expand Down
5 changes: 4 additions & 1 deletion tiledb/sm/query/writers/writer_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ WriterBase::WriterBase(
}

if (!skip_checks_serialization) {
check_subarray();
// Consolidation might set a subarray that is not tile aligned.
if (!disable_checks_consolidation) {
check_subarray();
}
check_buffer_sizes();
}

Expand Down