Skip to content

Commit

Permalink
Subarray, Domain, Dimension and TileDomain refactoring towards addres…
Browse files Browse the repository at this point in the history
…sing #93
  • Loading branch information
stavrospapadopoulos committed Mar 4, 2020
1 parent a56e579 commit 8efa144
Show file tree
Hide file tree
Showing 42 changed files with 1,839 additions and 2,107 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Now storing the coordinate tiles on each dimension in separate files
* Changed fragment name format from `__t1_t2_uuid` to `__t1_t2_uuid_<format_version>`. That was necessary for backwards compatibility

## Breaking C API changes

* Changed `domain` input of `tiledb_dimension_get_domain` to `const void**` (from `void**`).
* Changed `tile_extent` input of `tiledb_dimension_get_tile_extent` to `const void**` (from `void**`).

## New features

## Improvements
Expand Down
15 changes: 8 additions & 7 deletions test/src/helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ void check_subarray(

// Check ranges
uint64_t dim_range_num = 0;
const T* range;
const sm::Range* range;
for (unsigned i = 0; i < dim_num; ++i) {
CHECK(subarray.get_range_num(i, &dim_range_num).ok());
CHECK(dim_range_num == ranges[i].size() / 2);
for (uint64_t j = 0; j < dim_range_num; ++j) {
subarray.get_range(i, j, (const void**)&range);
CHECK(range[0] == ranges[i][2 * j]);
CHECK(range[1] == ranges[i][2 * j + 1]);
subarray.get_range(i, j, &range);
auto r = (const T*)range->data();
CHECK(r[0] == ranges[i][2 * j]);
CHECK(r[1] == ranges[i][2 * j + 1]);
}
}
}
Expand Down Expand Up @@ -412,10 +413,10 @@ void create_subarray(
tiledb::sm::Subarray ret(array, layout);

auto dim_num = (unsigned)ranges.size();
for (unsigned i = 0; i < dim_num; ++i) {
auto dim_range_num = ranges[i].size() / 2;
for (unsigned d = 0; d < dim_num; ++d) {
auto dim_range_num = ranges[d].size() / 2;
for (size_t j = 0; j < dim_range_num; ++j) {
ret.add_range(i, &ranges[i][2 * j]);
ret.add_range(d, sm::Range(&ranges[d][2 * j], 2 * sizeof(T)));
}
}

Expand Down
32 changes: 11 additions & 21 deletions test/src/unit-ReadCellSlabIter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,19 @@ void ReadCellSlabIterFx::create_result_space_tiles(
const std::vector<NDRange>& domain_slices,
const std::vector<std::vector<uint8_t>>& tile_coords,
std::map<const T*, ResultSpaceTile<T>>* result_space_tiles) {
auto dim_num = dom->dim_num();
auto domain = (const T*)dom->domain();
auto tile_extents = (const T*)dom->tile_extents();
auto domain = dom->domain();
const auto& tile_extents = dom->tile_extents();
std::vector<TileDomain<T>> frag_tile_domains;
for (size_t i = 0; i < domain_slices.size(); ++i) {
frag_tile_domains.emplace_back(
(unsigned)(domain_slices.size() - i),
dim_num,
domain,
domain_slices[i],
tile_extents,
layout);
}
TileDomain<T> array_tile_domain(
UINT32_MAX, dim_num, domain, dom_ndrange, tile_extents, layout);
UINT32_MAX, domain, dom_ndrange, tile_extents, layout);
Reader::compute_result_space_tiles<T>(
dom,
tile_coords,
Expand Down Expand Up @@ -231,10 +229,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -292,10 +289,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -356,10 +352,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -424,10 +419,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -648,10 +642,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -821,10 +814,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -1007,10 +999,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -1239,10 +1230,9 @@ TEST_CASE_METHOD(
const auto& tile_coords = subarray.tile_coords();
std::map<const uint64_t*, ResultSpaceTile<uint64_t>> result_space_tiles;
auto dom = array_->array_->array_schema()->domain();
auto dom_ndrange = dom->domain_ndrange();
create_result_space_tiles(
dom,
dom_ndrange,
dom->domain(),
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down
36 changes: 23 additions & 13 deletions test/src/unit-Reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ TEST_CASE_METHOD(
"[Reader][2d][compute_result_space_tiles]") {
Reader reader;
unsigned dim_num = 2;
std::vector<int32_t> domain = {1, 10, 1, 15};
std::vector<int32_t> tile_extents = {2, 5};
auto size = 2 * sizeof(int32_t);
int32_t domain_vec[] = {1, 10, 1, 15};
NDRange domain = {Range(&domain_vec[0], size), Range(&domain_vec[2], size)};
std::vector<int32_t> tile_extents_vec = {2, 5};
std::vector<ByteVecValue> tile_extents(2);
tile_extents[0].resize(sizeof(int32_t));
std::memcpy(&tile_extents[0][0], &tile_extents_vec[0], sizeof(int32_t));
tile_extents[1].resize(sizeof(int32_t));
std::memcpy(&tile_extents[1][0], &tile_extents_vec[1], sizeof(int32_t));
Layout layout = Layout::ROW_MAJOR;

// Tile coords
Expand Down Expand Up @@ -151,30 +158,33 @@ TEST_CASE_METHOD(
std::vector<int32_t> domain_slice_2 = {4, 5, 2, 4};
std::vector<int32_t> domain_slice_3 = {5, 7, 1, 9};

auto size = 2 * sizeof(int32_t);
NDRange ds1 = {Range(&domain_slice_1[0], size),
Range(&domain_slice_1[2], size)};
NDRange ds2 = {Range(&domain_slice_2[0], size),
Range(&domain_slice_2[2], size)};
NDRange ds3 = {Range(&domain_slice_3[0], size),
Range(&domain_slice_3[2], size)};
NDRange dsd = {Range(&domain[0], size), Range(&domain[2], size)};
NDRange dsd = domain;

std::vector<TileDomain<int32_t>> frag_tile_domains;
frag_tile_domains.emplace_back(TileDomain<int32_t>(
3, dim_num, &domain[0], ds3, &tile_extents[0], layout));
frag_tile_domains.emplace_back(TileDomain<int32_t>(
2, dim_num, &domain[0], ds2, &tile_extents[0], layout));
frag_tile_domains.emplace_back(TileDomain<int32_t>(
1, dim_num, &domain[0], ds1, &tile_extents[0], layout));
frag_tile_domains.emplace_back(
TileDomain<int32_t>(3, domain, ds3, tile_extents, layout));
frag_tile_domains.emplace_back(
TileDomain<int32_t>(2, domain, ds2, tile_extents, layout));
frag_tile_domains.emplace_back(
TileDomain<int32_t>(1, domain, ds1, tile_extents, layout));
TileDomain<int32_t> array_tile_domain(
UINT32_MAX, dim_num, &domain[0], dsd, &tile_extents[0], layout);
UINT32_MAX, domain, dsd, tile_extents, layout);

Dimension d1("d1", Datatype::INT32);
d1.set_domain(domain_vec);
d1.set_tile_extent(&tile_extents_vec[0]);
Dimension d2("d2", Datatype::INT32);
d2.set_domain(&domain_vec[2]);
d2.set_tile_extent(&tile_extents_vec[1]);
Domain dom(Datatype::INT32);
dom.add_dimension(&d1);
dom.add_dimension(&d2);
CHECK(dom.add_dimension(&d1).ok());
CHECK(dom.add_dimension(&d2).ok());

// Compute result space tiles map
std::map<const int32_t*, ResultSpaceTile<int32_t>> result_space_tiles;
Expand Down
8 changes: 4 additions & 4 deletions test/src/unit-Subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ TEST_CASE_METHOD(
std::vector<uint64_t> c_range_1_1 = {5, 5};
auto cropped_subarray =
subarray.crop_to_tile(&tile_coords[0], Layout::ROW_MAJOR);
const void* range = nullptr;
const Range* range = nullptr;
CHECK(cropped_subarray.range_num() == 2);
CHECK(cropped_subarray.get_range(0, 0, &range).ok());
CHECK(!memcmp(range, &c_range_0_0[0], 2 * sizeof(uint64_t)));
CHECK(!memcmp(range->data(), &c_range_0_0[0], 2 * sizeof(uint64_t)));
CHECK(cropped_subarray.get_range(1, 0, &range).ok());
CHECK(!memcmp(range, &c_range_1_0[0], 2 * sizeof(uint64_t)));
CHECK(!memcmp(range->data(), &c_range_1_0[0], 2 * sizeof(uint64_t)));
CHECK(cropped_subarray.get_range(1, 1, &range).ok());
CHECK(!memcmp(range, &c_range_1_1[0], 2 * sizeof(uint64_t)));
CHECK(!memcmp(range->data(), &c_range_1_1[0], 2 * sizeof(uint64_t)));

close_array(ctx_, array_);
}
Loading

0 comments on commit 8efa144

Please sign in to comment.