Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 committed Jan 31, 2024
1 parent 7e6d359 commit 89f6aec
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 9 deletions.
16 changes: 9 additions & 7 deletions tiledb/sm/serialization/query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ Subarray subarray_from_capnp(
// Edge case for dimension labels where there are only label ranges set.
if (ranges.empty()) {
range_subset[i] = RangeSetAndSuperset(
dim->type(), dim->domain(), false, coalesce_ranges);
}
// Add custom ranges, clearing any implicit ranges previously set.
for (const auto& range : ranges) {
throw_if_not_ok(range_subset[i].add_range_unrestricted(range));
dim->type(), dim->domain(), {dim->domain()}, coalesce_ranges);
} else {
// Add custom ranges, clearing any implicit ranges previously set.
range_subset[i] = RangeSetAndSuperset(
dim->type(), dim->domain(), ranges, coalesce_ranges);
}
}
} else {
Expand All @@ -324,11 +324,13 @@ Subarray subarray_from_capnp(

// Deserialize ranges for this dim label
auto range_reader = label_range_reader.getRanges();
auto ranges = range_buffers_from_capnp(range_reader);
auto label_ranges = range_buffers_from_capnp(range_reader);

// Set ranges for this dim label on the subarray
label_range_subset[dim_index] = {
label_name, dim->type(), coalesce_ranges};
label_name, dim->type(), label_ranges, coalesce_ranges};
range_subset[dim_index].clear();
is_default[dim_index] = false;
}
}

Expand Down
10 changes: 10 additions & 0 deletions tiledb/sm/subarray/range_subset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "tiledb/sm/subarray/range_subset.h"

#include <iostream>
#include <utility>

using namespace tiledb::common;
using namespace tiledb::type;
Expand Down Expand Up @@ -131,6 +132,15 @@ RangeSetAndSuperset::RangeSetAndSuperset(
ranges_.emplace_back(superset);
}

RangeSetAndSuperset::RangeSetAndSuperset(
Datatype datatype,
const Range& superset,
std::vector<Range> subset,
bool coalesce_ranges)
: RangeSetAndSuperset(datatype, superset, false, coalesce_ranges) {
ranges_ = std::move(subset);
}

void RangeSetAndSuperset::sort_and_merge_ranges(
ThreadPool* const compute_tp, bool merge) {
if (ranges_.empty()) {
Expand Down
20 changes: 18 additions & 2 deletions tiledb/sm/subarray/range_subset.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,33 @@ class RangeSetAndSuperset {
/** General constructor
*
* @param datatype The TileDB datatype of of the ranges.
* @param superset The superset of ranges to initialize the range set.
* @param implicitly_initialize If ``true``, set the ranges to contain the
* full superset until a new range is explicitly added.
* full superset until a new range is explicitly added.
* @param coalesce_ranges If ``true``, when adding a new range, attempt to
* combine with the first left-adjacent range found.
* combine with the first left-adjacent range found.
**/
RangeSetAndSuperset(
Datatype datatype,
const Range& superset,
bool implicitly_initialize,
bool coalesce_ranges);

/**
* Constructor.
*
* @param datatype The TileDB datatype of of the ranges.
* @param superset The superset of ranges to initialize the range set.
* @param subset The subset of ranges to initialize the range set.
* @param coalesce_ranges If ``true``, when adding a new range, attempt to
* combine with the first left-adjacent range found.
**/
RangeSetAndSuperset(
Datatype datatype,
const Range& superset,
std::vector<Range> subset,
bool coalesce_ranges);

/** Destructor. */
~RangeSetAndSuperset() = default;

Expand Down
10 changes: 10 additions & 0 deletions tiledb/sm/subarray/subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3260,5 +3260,15 @@ Subarray::LabelRangeSubset::LabelRangeSubset(
, ranges_{RangeSetAndSuperset(type, Range(), false, coalesce_ranges)} {
}

Subarray::LabelRangeSubset::LabelRangeSubset(
const std::string& name,
Datatype type,
std::vector<Range> ranges,
bool coalesce_ranges)
: name_{name}
, ranges_{RangeSetAndSuperset(
type, Range(), std::move(ranges), coalesce_ranges)} {
}

} // namespace sm
} // namespace tiledb
14 changes: 14 additions & 0 deletions tiledb/sm/subarray/subarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ class Subarray {
LabelRangeSubset(
const std::string& name, Datatype type, bool coalesce_ranges = true);

/**
* Constructor
*
* @param name The name of the dimension label the ranges will be set on.
* @param type The type of the label the ranges will be set on.
* @param ranges The range subset for the dimension label.
* @param coalesce_ranges Set if ranges should be combined when adjacent.
*/
LabelRangeSubset(
const std::string& name,
Datatype type,
std::vector<Range> ranges,
bool coalesce_ranges = true);

inline const std::vector<Range>& get_ranges() const {
return ranges_.ranges();
}
Expand Down

0 comments on commit 89f6aec

Please sign in to comment.