Skip to content

Commit

Permalink
Use reserve for label_range_subset
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 committed Feb 16, 2024
1 parent 9d8943a commit e4fcc1c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tiledb/sm/serialization/query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,27 +303,41 @@ Subarray subarray_from_capnp(
}
}

std::vector<optional<Subarray::LabelRangeSubset>> label_range_subset(
dim_num, nullopt);
std::vector<optional<Subarray::LabelRangeSubset>> label_range_subset;
label_range_subset.reserve(dim_num);
uint32_t last_dim = 0;
if (reader.hasLabelRanges()) {
auto label_ranges_reader = reader.getLabelRanges();
uint32_t label_num = label_ranges_reader.size();
for (uint32_t i = 0; i < label_num; i++) {
auto label_range_reader = label_ranges_reader[i];
auto dim_index = label_range_reader.getDimensionId();
auto dim = array->array_schema_latest().dimension_ptr(dim_index);

// Fill in any missing dimensions with nullopt
for (; last_dim < dim_index; last_dim++) {
label_range_subset.emplace_back(std::nullopt);
}
auto label_name = label_range_reader.getName();

// Deserialize ranges for this dim label
auto range_reader = label_range_reader.getRanges();
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(), label_ranges, coalesce_ranges};
label_range_subset.emplace_back(
std::in_place,
label_name,
dim->type(),
label_ranges,
coalesce_ranges);
is_default[dim_index] = false;
}
}
// Fill in label ranges with nullopt for any remaining dimensions
for (; last_dim < dim_num; last_dim++) {
label_range_subset.emplace_back(std::nullopt);
}

std::unordered_map<std::string, std::vector<Range>> attr_range_subset;
if (reader.hasAttributeRanges()) {
Expand Down

0 comments on commit e4fcc1c

Please sign in to comment.