Skip to content

Commit 4a1838f

Browse files
shaunrd0KiterLuc
authored andcommitted
Fix test
1 parent d566ce5 commit 4a1838f

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
@@ -291,11 +291,11 @@ Subarray subarray_from_capnp(
291291
// Edge case for dimension labels where there are only label ranges set.
292292
if (ranges.empty()) {
293293
range_subset[i] = RangeSetAndSuperset(
294-
dim->type(), dim->domain(), false, coalesce_ranges);
295-
}
296-
// Add custom ranges, clearing any implicit ranges previously set.
297-
for (const auto& range : ranges) {
298-
throw_if_not_ok(range_subset[i].add_range_unrestricted(range));
294+
dim->type(), dim->domain(), {dim->domain()}, coalesce_ranges);
295+
} else {
296+
// Add custom ranges, clearing any implicit ranges previously set.
297+
range_subset[i] = RangeSetAndSuperset(
298+
dim->type(), dim->domain(), ranges, coalesce_ranges);
299299
}
300300
}
301301
} else {
@@ -320,11 +320,13 @@ Subarray subarray_from_capnp(
320320

321321
// Deserialize ranges for this dim label
322322
auto range_reader = label_range_reader.getRanges();
323-
auto ranges = range_buffers_from_capnp(range_reader);
323+
auto label_ranges = range_buffers_from_capnp(range_reader);
324324

325325
// Set ranges for this dim label on the subarray
326326
label_range_subset[dim_index] = {
327-
label_name, dim->type(), coalesce_ranges};
327+
label_name, dim->type(), label_ranges, coalesce_ranges};
328+
range_subset[dim_index].clear();
329+
is_default[dim_index] = false;
328330
}
329331
}
330332

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
@@ -3287,5 +3287,15 @@ Subarray::LabelRangeSubset::LabelRangeSubset(
32873287
, ranges_{RangeSetAndSuperset(type, Range(), false, coalesce_ranges)} {
32883288
}
32893289

3290+
Subarray::LabelRangeSubset::LabelRangeSubset(
3291+
const std::string& name,
3292+
Datatype type,
3293+
std::vector<Range> ranges,
3294+
bool coalesce_ranges)
3295+
: name_{name}
3296+
, ranges_{RangeSetAndSuperset(
3297+
type, Range(), std::move(ranges), coalesce_ranges)} {
3298+
}
3299+
32903300
} // namespace sm
32913301
} // 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)