Skip to content

Commit f03f0b1

Browse files
committed
Fix test
1 parent 4a47105 commit f03f0b1

File tree

5 files changed

+61
-9
lines changed

5 files changed

+61
-9
lines changed

tiledb/sm/serialization/query.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ Subarray subarray_from_capnp(
295295
// Edge case for dimension labels where there are only label ranges set.
296296
if (ranges.empty()) {
297297
range_subset[i] = RangeSetAndSuperset(
298-
dim->type(), dim->domain(), false, coalesce_ranges);
299-
}
300-
// Add custom ranges, clearing any implicit ranges previously set.
301-
for (const auto& range : ranges) {
302-
throw_if_not_ok(range_subset[i].add_range_unrestricted(range));
298+
dim->type(), dim->domain(), {dim->domain()}, coalesce_ranges);
299+
} else {
300+
// Add custom ranges, clearing any implicit ranges previously set.
301+
range_subset[i] = RangeSetAndSuperset(
302+
dim->type(), dim->domain(), ranges, coalesce_ranges);
303303
}
304304
}
305305
} else {
@@ -324,11 +324,13 @@ Subarray subarray_from_capnp(
324324

325325
// Deserialize ranges for this dim label
326326
auto range_reader = label_range_reader.getRanges();
327-
auto ranges = range_buffers_from_capnp(range_reader);
327+
auto label_ranges = range_buffers_from_capnp(range_reader);
328328

329329
// Set ranges for this dim label on the subarray
330330
label_range_subset[dim_index] = {
331-
label_name, dim->type(), coalesce_ranges};
331+
label_name, dim->type(), label_ranges, coalesce_ranges};
332+
range_subset[dim_index].clear();
333+
is_default[dim_index] = false;
332334
}
333335
}
334336

tiledb/sm/subarray/range_subset.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "tiledb/sm/subarray/range_subset.h"
3434

3535
#include <iostream>
36+
#include <utility>
3637

3738
using namespace tiledb::common;
3839
using namespace tiledb::type;
@@ -131,6 +132,15 @@ RangeSetAndSuperset::RangeSetAndSuperset(
131132
ranges_.emplace_back(superset);
132133
}
133134

135+
RangeSetAndSuperset::RangeSetAndSuperset(
136+
Datatype datatype,
137+
const Range& superset,
138+
std::vector<Range> subset,
139+
bool coalesce_ranges)
140+
: RangeSetAndSuperset(datatype, superset, false, coalesce_ranges) {
141+
ranges_ = std::move(subset);
142+
}
143+
134144
void RangeSetAndSuperset::sort_and_merge_ranges(
135145
ThreadPool* const compute_tp, bool merge) {
136146
if (ranges_.empty()) {

tiledb/sm/subarray/range_subset.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,33 @@ class RangeSetAndSuperset {
429429
/** General constructor
430430
*
431431
* @param datatype The TileDB datatype of of the ranges.
432+
* @param superset The superset of ranges to initialize the range set.
432433
* @param implicitly_initialize If ``true``, set the ranges to contain the
433-
* full superset until a new range is explicitly added.
434+
* full superset until a new range is explicitly added.
434435
* @param coalesce_ranges If ``true``, when adding a new range, attempt to
435-
* combine with the first left-adjacent range found.
436+
* combine with the first left-adjacent range found.
436437
**/
437438
RangeSetAndSuperset(
438439
Datatype datatype,
439440
const Range& superset,
440441
bool implicitly_initialize,
441442
bool coalesce_ranges);
442443

444+
/**
445+
* Constructor.
446+
*
447+
* @param datatype The TileDB datatype of of the ranges.
448+
* @param superset The superset of ranges to initialize the range set.
449+
* @param subset The subset of ranges to initialize the range set.
450+
* @param coalesce_ranges If ``true``, when adding a new range, attempt to
451+
* combine with the first left-adjacent range found.
452+
**/
453+
RangeSetAndSuperset(
454+
Datatype datatype,
455+
const Range& superset,
456+
std::vector<Range> subset,
457+
bool coalesce_ranges);
458+
443459
/** Destructor. */
444460
~RangeSetAndSuperset() = default;
445461

tiledb/sm/subarray/subarray.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,5 +3260,15 @@ Subarray::LabelRangeSubset::LabelRangeSubset(
32603260
, ranges_{RangeSetAndSuperset(type, Range(), false, coalesce_ranges)} {
32613261
}
32623262

3263+
Subarray::LabelRangeSubset::LabelRangeSubset(
3264+
const std::string& name,
3265+
Datatype type,
3266+
std::vector<Range> ranges,
3267+
bool coalesce_ranges)
3268+
: name_{name}
3269+
, ranges_{RangeSetAndSuperset(
3270+
type, Range(), std::move(ranges), coalesce_ranges)} {
3271+
}
3272+
32633273
} // namespace sm
32643274
} // namespace tiledb

tiledb/sm/subarray/subarray.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ class Subarray {
234234
LabelRangeSubset(
235235
const std::string& name, Datatype type, bool coalesce_ranges = true);
236236

237+
/**
238+
* Constructor
239+
*
240+
* @param name The name of the dimension label the ranges will be set on.
241+
* @param type The type of the label the ranges will be set on.
242+
* @param ranges The range subset for the dimension label.
243+
* @param coalesce_ranges Set if ranges should be combined when adjacent.
244+
*/
245+
LabelRangeSubset(
246+
const std::string& name,
247+
Datatype type,
248+
std::vector<Range> ranges,
249+
bool coalesce_ranges = true);
250+
237251
inline const std::vector<Range>& get_ranges() const {
238252
return ranges_.ranges();
239253
}

0 commit comments

Comments
 (0)