Skip to content

Commit

Permalink
Refactoring towards addressing #93. (#1509)
Browse files Browse the repository at this point in the history
Mainly refactored fragment non-empty domain in FragmentMetadata and the way the tile MBRs are computed in Worker.
  • Loading branch information
stavrospapadopoulos authored Feb 19, 2020
1 parent fb4aec1 commit 6d6dce5
Show file tree
Hide file tree
Showing 26 changed files with 1,370 additions and 870 deletions.
99 changes: 78 additions & 21 deletions test/src/unit-ReadCellSlabIter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ struct ReadCellSlabIterFx {
template <class T>
void create_result_space_tiles(
const Domain* dom,
const NDRange& dom_ndrange,
Layout layout,
const std::vector<std::vector<T>>& domain_slices,
const std::vector<NDRange>& domain_slices,
const std::vector<std::vector<uint8_t>>& tile_coords,
std::map<const T*, ResultSpaceTile<T>>* result_space_tiles);
};
Expand Down Expand Up @@ -141,8 +142,9 @@ void ReadCellSlabIterFx::check_iter(
template <class T>
void ReadCellSlabIterFx::create_result_space_tiles(
const Domain* dom,
const NDRange& dom_ndrange,
Layout layout,
const std::vector<std::vector<T>>& domain_slices,
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();
Expand All @@ -154,12 +156,12 @@ void ReadCellSlabIterFx::create_result_space_tiles(
(unsigned)(domain_slices.size() - i),
dim_num,
domain,
&(domain_slices[i][0]),
domain_slices[i],
tile_extents,
layout);
}
TileDomain<T> array_tile_domain(
UINT32_MAX, dim_num, domain, domain, tile_extents, layout);
UINT32_MAX, dim_num, domain, dom_ndrange, tile_extents, layout);
Reader::compute_result_space_tiles<T>(
dom,
tile_coords,
Expand Down Expand Up @@ -218,11 +220,16 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{1, 100}};
std::vector<uint64_t> slice = {1, 100};
NDRange ds = {Range(&slice[0], 2 * sizeof(uint64_t))};
std::vector<NDRange> domain_slices = {ds};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -274,11 +281,16 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{20, 30}};
std::vector<uint64_t> slice = {20, 30};
NDRange ds = {Range(&slice[0], 2 * sizeof(uint64_t))};
std::vector<NDRange> domain_slices = {ds};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -330,11 +342,19 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{5, 12}, {4, 15}};
std::vector<uint64_t> slice_1 = {5, 12};
std::vector<uint64_t> slice_2 = {4, 15};
auto size = 2 * sizeof(uint64_t);
NDRange ds1 = {Range(&slice_1[0], size)};
NDRange ds2 = {Range(&slice_2[0], size)};
std::vector<NDRange> domain_slices = {ds1, ds2};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
subarray_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -392,12 +412,21 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{3, 12}};
std::vector<uint64_t> slice = {3, 12};
auto size = 2 * sizeof(uint64_t);
NDRange ds = {Range(&slice[0], size)};
std::vector<NDRange> domain_slices = {ds};
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, subarray_layout, domain_slices, tile_coords, &result_space_tiles);
dom,
dom_ndrange,
subarray_layout,
domain_slices,
tile_coords,
&result_space_tiles);

// Create result coordinates
std::vector<ResultCoords> result_coords;
Expand Down Expand Up @@ -607,11 +636,17 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{1, 6, 1, 6}};
std::vector<uint64_t> slice = {1, 6, 1, 6};
auto size = 2 * sizeof(uint64_t);
NDRange ds = {Range(&slice[0], size), Range(&slice[2], size)};
std::vector<NDRange> domain_slices = {ds};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -774,11 +809,17 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{6, 6, 6, 6}};
std::vector<uint64_t> slice = {6, 6, 6, 6};
auto size = 2 * sizeof(uint64_t);
NDRange ds = {Range(&slice[0], size), Range(&slice[2], size)};
std::vector<NDRange> domain_slices = {ds};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -954,11 +995,17 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{3, 6, 5, 6}};
std::vector<uint64_t> slice = {3, 6, 5, 6};
auto size = 2 * sizeof(uint64_t);
NDRange ds = {Range(&slice[0], size), Range(&slice[2], size)};
std::vector<NDRange> domain_slices = {ds};
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(
array_->array_->array_schema()->domain(),
dom,
dom_ndrange,
tile_domain_layout,
domain_slices,
tile_coords,
Expand Down Expand Up @@ -1178,13 +1225,23 @@ TEST_CASE_METHOD(
subarray.compute_tile_coords<uint64_t>();

// Create result space tiles
std::vector<std::vector<uint64_t>> domain_slices = {{3, 5, 2, 4},
{2, 3, 1, 6}};
std::vector<uint64_t> slice_1 = {3, 5, 2, 4};
std::vector<uint64_t> slice_2 = {2, 3, 1, 6};
auto size = 2 * sizeof(uint64_t);
NDRange ds1 = {Range(&slice_1[0], size), Range(&slice_1[2], size)};
NDRange ds2 = {Range(&slice_2[0], size), Range(&slice_2[2], size)};
std::vector<NDRange> domain_slices = {ds1, ds2};
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, tile_domain_layout, domain_slices, tile_coords, &result_space_tiles);
dom,
dom_ndrange,
tile_domain_layout,
domain_slices,
tile_coords,
&result_space_tiles);

// Create result coordinates
std::vector<ResultCoords> result_coords;
Expand Down
80 changes: 37 additions & 43 deletions test/src/unit-Reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "test/src/helpers.h"
#include "tiledb/sm/c_api/tiledb_struct_def.h"
#include "tiledb/sm/misc/types.h"
#include "tiledb/sm/query/reader.h"

#ifdef _WIN32
Expand Down Expand Up @@ -144,15 +145,25 @@ TEST_CASE_METHOD(
std::vector<int32_t> domain_slice_1 = {3, 4, 1, 12};
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)};

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

Dimension d1("d1", Datatype::INT32);
Dimension d2("d2", Datatype::INT32);
Expand Down Expand Up @@ -181,46 +192,29 @@ TEST_CASE_METHOD(
ResultTile result_tile_2_0_3(3, 0, &dom);
ResultTile result_tile_3_0_3(3, 2, &dom);

// Initialize frag domains
typedef std::pair<unsigned, const int32_t*> FragDomain;
std::vector<FragDomain> frag_domain_1_0 = {FragDomain(2, &domain_slice_2[0]),
FragDomain(1, &domain_slice_1[0])};
std::vector<FragDomain> frag_domain_1_2 = {FragDomain(1, &domain_slice_1[0])};
std::vector<FragDomain> frag_domain_2_0 = {FragDomain(3, &domain_slice_3[0])};
std::vector<FragDomain> frag_domain_3_0 = {FragDomain(3, &domain_slice_3[0])};
std::vector<FragDomain> frag_domain_2_2 = {};
std::vector<FragDomain> frag_domain_3_2 = {};

// Initialize result tiles
std::map<unsigned, ResultTile> result_tiles_1_0 = {
std::pair<unsigned, ResultTile>(1, result_tile_1_0_1),
std::pair<unsigned, ResultTile>(2, result_tile_1_0_2),
};
std::map<unsigned, ResultTile> result_tiles_1_2 = {
std::pair<unsigned, ResultTile>(1, result_tile_1_2_1),
};
std::map<unsigned, ResultTile> result_tiles_2_0 = {
std::pair<unsigned, ResultTile>(3, result_tile_2_0_3),
};
std::map<unsigned, ResultTile> result_tiles_3_0 = {
std::pair<unsigned, ResultTile>(3, result_tile_3_0_3),
};
std::map<unsigned, ResultTile> result_tiles_2_2 = {};
std::map<unsigned, ResultTile> result_tiles_3_2 = {};

// Initialize result_space_tiles
ResultSpaceTile<int32_t> rst_1_0 = {
{3, 1}, frag_domain_1_0, result_tiles_1_0};
ResultSpaceTile<int32_t> rst_1_2 = {
{3, 11}, frag_domain_1_2, result_tiles_1_2};
ResultSpaceTile<int32_t> rst_2_0 = {
{5, 1}, frag_domain_2_0, result_tiles_2_0};
ResultSpaceTile<int32_t> rst_2_2 = {
{5, 11}, frag_domain_2_2, result_tiles_2_2};
ResultSpaceTile<int32_t> rst_3_0 = {
{7, 1}, frag_domain_3_0, result_tiles_3_0};
ResultSpaceTile<int32_t> rst_3_2 = {
{7, 11}, frag_domain_3_2, result_tiles_3_2};
ResultSpaceTile<int32_t> rst_1_0;
rst_1_0.set_start_coords({3, 1});
rst_1_0.append_frag_domain(2, ds2);
rst_1_0.append_frag_domain(1, ds1);
rst_1_0.set_result_tile(1, result_tile_1_0_1);
rst_1_0.set_result_tile(2, result_tile_1_0_2);
ResultSpaceTile<int32_t> rst_1_2;
rst_1_2.set_start_coords({3, 11});
rst_1_2.append_frag_domain(1, ds1);
rst_1_2.set_result_tile(1, result_tile_1_2_1);
ResultSpaceTile<int32_t> rst_2_0;
rst_2_0.set_start_coords({5, 1});
rst_2_0.append_frag_domain(3, ds3);
rst_2_0.set_result_tile(3, result_tile_2_0_3);
ResultSpaceTile<int32_t> rst_2_2;
rst_2_2.set_start_coords({5, 11});
ResultSpaceTile<int32_t> rst_3_0;
rst_3_0.set_start_coords({7, 1});
rst_3_0.append_frag_domain(3, ds3);
rst_3_0.set_result_tile(3, result_tile_3_0_3);
ResultSpaceTile<int32_t> rst_3_2;
rst_3_2.set_start_coords({7, 11});

// Prepare correct space tiles map
std::map<const int32_t*, ResultSpaceTile<int32_t>> c_result_space_tiles;
Expand Down
Loading

0 comments on commit 6d6dce5

Please sign in to comment.