MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / get_expanded_coordinates

Method get_expanded_coordinates

tiledb/sm/subarray/subarray.cc:2537–2610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2535}
2536
2537void Subarray::get_expanded_coordinates(
2538 const uint64_t range_idx_start,
2539 const uint64_t range_idx_end,
2540 std::vector<uint64_t>* const start_coords,
2541 std::vector<uint64_t>* const end_coords) const {
2542 // Fetch the multi-dimensional coordinates from the
2543 // flattened (total order) range indexes.
2544 *start_coords = get_range_coords(range_idx_start);
2545 *end_coords = get_range_coords(range_idx_end);
2546
2547 // This is only applicable to row-major, column-major, or unordered
2548 // layouts. We will treat unordered layouts as the cell layout.
2549 const Layout coords_layout =
2550 (layout_ == Layout::UNORDERED) ?
2551 ((cell_order_ == Layout::HILBERT) ? Layout::ROW_MAJOR : cell_order_) :
2552 layout_;
2553 if (coords_layout == Layout::GLOBAL_ORDER ||
2554 coords_layout == Layout::HILBERT) {
2555 iassert(*start_coords == *end_coords);
2556 return;
2557 }
2558
2559 iassert(
2560 coords_layout == Layout::ROW_MAJOR || coords_layout == Layout::COL_MAJOR,
2561 "layout = {}",
2562 layout_str(coords_layout));
2563
2564 const uint32_t dim_num = array_->array_schema_latest().dim_num();
2565
2566 // Locate the first dimension where the start/end coordinates deviate.
2567 int64_t deviation_d;
2568 if (coords_layout == Layout::ROW_MAJOR) {
2569 deviation_d = 0;
2570 while (deviation_d < dim_num - 1) {
2571 if ((*start_coords)[deviation_d] != (*end_coords)[deviation_d])
2572 break;
2573 ++deviation_d;
2574 }
2575 } else {
2576 passert(coords_layout == Layout::COL_MAJOR);
2577 deviation_d = dim_num - 1;
2578 while (deviation_d > 0) {
2579 if ((*start_coords)[deviation_d] != (*end_coords)[deviation_d])
2580 break;
2581 --deviation_d;
2582 }
2583 }
2584
2585 // Calculate the first dimension to start the expansion. This is the
2586 // the dimension that immediately follows the dimension where the
2587 // coordinates deviate.
2588 int64_t expand_d;
2589 if (coords_layout == Layout::ROW_MAJOR) {
2590 expand_d = deviation_d + 1;
2591 } else {
2592 passert(coords_layout == Layout::COL_MAJOR);
2593 expand_d = deviation_d - 1;
2594 }

Callers 3

update_range_coordsMethod · 0.80

Calls 3

array_schema_latestMethod · 0.80
num_rangesMethod · 0.80
dim_numMethod · 0.45

Tested by

no test coverage detected