Skip to content

Commit 0315fa1

Browse files
committed
fix failing tests
1 parent bd0c539 commit 0315fa1

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

Framework/Core/include/Framework/ArrowTableSlicingCache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ namespace o2::framework
2121
using ListVector = std::vector<std::vector<int64_t>>;
2222

2323
struct SliceInfoPtr {
24-
gsl::span<int const> values;
25-
gsl::span<int64_t const> counts;
2624
std::vector<int64_t> const* offsets;
2725
std::vector<int64_t> const* sizes;
2826

Framework/Core/include/Framework/GroupSlicer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ struct GroupSlicer {
246246
pos = position;
247247
}
248248
// optimized split
249-
auto oc = sliceInfos[index].getSliceFor(pos);
250-
uint64_t offset = oc.first;
251-
auto count = oc.second;
249+
auto [offset, count] = sliceInfos[index].getSliceFor(pos);
252250
auto groupedElementsTable = originalTable.rawSlice(offset, offset + count - 1);
253251
groupedElementsTable.bindInternalIndicesTo(&originalTable);
254252
return groupedElementsTable;

Framework/Core/src/ArrowTableSlicingCache.cxx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ void updatePairList(Cache& list, std::string const& binding, std::string const&
3232
std::pair<int64_t, int64_t> SliceInfoPtr::getSliceFor(int value) const
3333
{
3434
int64_t offset = 0;
35-
if (values.empty()) {
35+
if ((*offsets).empty()) {
36+
return {offset, 0};
37+
}
38+
if ((size_t)value > (*offsets).size()) {
3639
return {offset, 0};
3740
}
3841

@@ -117,7 +120,7 @@ arrow::Status ArrowTableSlicingCache::updateCacheEntry(int pos, std::shared_ptr<
117120
values[pos] = std::make_shared<arrow::NumericArray<arrow::Int32Type>>(pair.field(0)->data());
118121
counts[pos] = std::make_shared<arrow::NumericArray<arrow::Int64Type>>(pair.field(1)->data());
119122

120-
int maxValue = 0;
123+
int maxValue = -1;
121124
for (auto i = values[pos]->length() - 1; i >= 0; --i) {
122125
if (values[pos]->Value(i) < 0) {
123126
continue;
@@ -128,7 +131,7 @@ arrow::Status ArrowTableSlicingCache::updateCacheEntry(int pos, std::shared_ptr<
128131
}
129132

130133
offsets[pos].resize(maxValue + 1);
131-
sizes[pos].resize(maxValue);
134+
sizes[pos].resize(maxValue + 1);
132135
std::fill(offsets[pos].begin(), offsets[pos].end(), 0);
133136
std::fill(sizes[pos].begin(), sizes[pos].end(), 0);
134137
int64_t offset = 0;
@@ -140,7 +143,6 @@ arrow::Status ArrowTableSlicingCache::updateCacheEntry(int pos, std::shared_ptr<
140143
}
141144
offset += counts[pos]->Value(i);
142145
}
143-
offsets[pos][maxValue] = offset;
144146
return arrow::Status::OK();
145147
}
146148

@@ -237,16 +239,12 @@ SliceInfoPtr ArrowTableSlicingCache::getCacheForPos(int pos) const
237239
{
238240
if (values[pos] == nullptr && counts[pos] == nullptr) {
239241
return {
240-
{},//
241-
{},//
242242
nullptr, //
243243
nullptr //
244244
};
245245
}
246246

247247
return {
248-
{reinterpret_cast<int const*>(values[pos]->values()->data()), static_cast<size_t>(values[pos]->length())}, //
249-
{reinterpret_cast<int64_t const*>(counts[pos]->values()->data()), static_cast<size_t>(counts[pos]->length())}, //
250248
&(offsets[pos]), //
251249
&(sizes[pos]) //
252250
};

Framework/Core/test/test_GroupSlicer.cxx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,21 +260,19 @@ TEST_CASE("GroupSlicerMismatchedGroups")
260260
auto s = slices.updateCacheEntry(0, trkTable);
261261
o2::framework::GroupSlicer g(e, tt, slices);
262262

263-
auto count = 0;
264263
for (auto& slice : g) {
265264
auto as = slice.associatedTables();
266265
auto gg = slice.groupingElement();
267-
REQUIRE(gg.globalIndex() == count);
266+
REQUIRE(gg.globalIndex() == (int64_t)slice.position);
268267
auto trks = std::get<aod::TrksX>(as);
269-
if (count == 3 || count == 10 || count == 12 || count == 16 || count == 19) {
268+
if (slice.position == 3 || slice.position == 10 || slice.position == 12 || slice.position == 16 || slice.position == 19) {
270269
REQUIRE(trks.size() == 0);
271270
} else {
272271
REQUIRE(trks.size() == 10);
273272
}
274273
for (auto& trk : trks) {
275-
REQUIRE(trk.eventId() == count);
274+
REQUIRE(trk.eventId() == (int64_t)slice.position);
276275
}
277-
++count;
278276
}
279277
}
280278

@@ -510,7 +508,7 @@ TEST_CASE("GroupSlicerMismatchedUnsortedFilteredGroupsWithSelfIndex")
510508
{
511509
TableBuilder builderE;
512510
auto evtsWriter = builderE.cursor<aod::Events>();
513-
for (auto i = 0; i < 20; ++i) {
511+
for (auto i = 0; i < 10; ++i) {
514512
evtsWriter(0, i, 0.5f * i, 2.f * i, 3.f * i);
515513
}
516514
auto evtTable = builderE.finalize();
@@ -523,13 +521,12 @@ TEST_CASE("GroupSlicerMismatchedUnsortedFilteredGroupsWithSelfIndex")
523521
std::uniform_int_distribution<> distrib(0, 99);
524522

525523
for (auto i = 0; i < 100; ++i) {
526-
527524
filler[0] = distrib(gen);
528525
filler[1] = distrib(gen);
529526
if (filler[0] > filler[1]) {
530527
std::swap(filler[0], filler[1]);
531528
}
532-
partsWriter(0, std::floor(i / 10.), i, filler);
529+
partsWriter(0, std::floor( i / 10.), i, filler);
533530
}
534531
auto partsTable = builderP.finalize();
535532

@@ -541,7 +538,6 @@ TEST_CASE("GroupSlicerMismatchedUnsortedFilteredGroupsWithSelfIndex")
541538
auto thingsTable = builderT.finalize();
542539

543540
aod::Events e{evtTable};
544-
// aod::Parts p{partsTable};
545541
aod::Things t{thingsTable};
546542
using FilteredParts = soa::Filtered<aod::Parts>;
547543
auto size = distrib(gen);

0 commit comments

Comments
 (0)