Skip to content

Commit 4e57361

Browse files
aalkinsawenzel
authored andcommitted
fix filtered grouping for merged AODs
1 parent 35d4013 commit 4e57361

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Framework/Core/include/Framework/AnalysisTask.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ struct AnalysisDataProcessorBuilder {
282282
x.asArrowTable(),
283283
static_cast<int32_t>(gt.tableSize()),
284284
&groups[index],
285-
&offsets[index]);
285+
&offsets[index],
286+
&sizes[index]);
286287
if (result.ok() == false) {
287288
throw runtime_error("Cannot split collection");
288289
}
@@ -394,7 +395,7 @@ struct AnalysisDataProcessorBuilder {
394395

395396
// for each grouping element we need to slice the selection vector
396397
auto start_iterator = std::lower_bound(starts[index], selections[index]->end(), (offsets[index])[pos]);
397-
auto stop_iterator = std::lower_bound(start_iterator, selections[index]->end(), (offsets[index])[pos + 1]);
398+
auto stop_iterator = std::lower_bound(start_iterator, selections[index]->end(), (offsets[index])[pos] + (sizes[index])[pos]);
398399
starts[index] = stop_iterator;
399400
soa::SelectionVector slicedSelection{start_iterator, stop_iterator};
400401
std::transform(slicedSelection.begin(), slicedSelection.end(), slicedSelection.begin(),
@@ -421,6 +422,7 @@ struct AnalysisDataProcessorBuilder {
421422
soa::SelectionVector const* groupSelection = nullptr;
422423
std::array<std::vector<arrow::Datum>, sizeof...(A)> groups;
423424
std::array<std::vector<uint64_t>, sizeof...(A)> offsets;
425+
std::array<std::vector<int>, sizeof...(A)> sizes;
424426
std::array<soa::SelectionVector const*, sizeof...(A)> selections;
425427
std::array<soa::SelectionVector::const_iterator, sizeof...(A)> starts;
426428
};

Framework/Core/include/Framework/Kernels.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ auto sliceByColumn(
3636
T fullSize,
3737
std::vector<arrow::Datum>* slices,
3838
std::vector<uint64_t>* offsets = nullptr,
39+
std::vector<int>* sizes = nullptr,
3940
std::vector<arrow::Datum>* unassignedSlices = nullptr,
4041
std::vector<uint64_t>* unassignedOffsets = nullptr)
4142
{
@@ -50,7 +51,6 @@ auto sliceByColumn(
5051

5152
// create slices and offsets
5253
uint64_t offset = 0;
53-
uint64_t unassignedOffset = 0;
5454
auto count = 0;
5555
auto size = values.length();
5656

@@ -59,6 +59,9 @@ auto sliceByColumn(
5959
if (offsets) {
6060
offsets->emplace_back(offset_);
6161
}
62+
if (sizes) {
63+
sizes->emplace_back(count_);
64+
}
6265
};
6366

6467
auto makeUnassignedSlice = [&](uint64_t offset_, T count_) {
@@ -85,7 +88,7 @@ auto sliceByColumn(
8588
offset += count;
8689
continue;
8790
}
88-
nzeros = v - vprev - ((i == 0) ? 0 : 1);
91+
nzeros = v - vprev - ((i == 0 || slices->empty() == true) ? 0 : 1);
8992
for (auto z = 0; z < nzeros; ++z) {
9093
makeSlice(offset, 0);
9194
}

0 commit comments

Comments
 (0)