Skip to content

Commit ae3ee6e

Browse files
Minor cleanup: adding function to match DataHeader to Input/OutputSpec
1 parent da5a51c commit ae3ee6e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Framework/Core/include/Framework/DataSpecUtils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ struct DataSpecUtils {
5151
const o2::header::DataDescription& description,
5252
const o2::header::DataHeader::SubSpecificationType& subSpec);
5353

54+
static bool match(const InputSpec& spec, o2::header::DataHeader const& dh)
55+
{
56+
return DataSpecUtils::match(spec, dh.dataOrigin, dh.dataDescription, dh.subSpecification);
57+
}
58+
59+
static bool match(const OutputSpec& spec, o2::header::DataHeader const& dh)
60+
{
61+
return DataSpecUtils::match(spec, dh.dataOrigin, dh.dataDescription, dh.subSpecification);
62+
}
63+
5464
/// find a matching spec in the container
5565
/// @return std::optional with found spec or std::nullopt
5666
template <typename ContainerT>

Framework/Core/src/ArrowSupport.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,16 @@ o2::framework::ServiceSpec ArrowSupport::arrowBackendSpec()
361361
if (input.header == nullptr) {
362362
continue;
363363
}
364-
auto dh = o2::header::get<DataHeader*>(input.header);
364+
auto const* dh = DataRefUtils::getHeader<DataHeader*>(input);
365+
auto payloadSize = DataRefUtils::getPayloadSize(input);
365366
if (dh->serialization != o2::header::gSerializationMethodArrow) {
366367
LOGP(debug, "Message {}/{} is not of kind arrow, therefore we are not accounting its shared memory", dh->dataOrigin, dh->dataDescription);
367368
continue;
368369
}
369370
auto dph = o2::header::get<DataProcessingHeader*>(input.header);
370371
bool forwarded = false;
371372
for (auto const& forward : ctx.services().get<DeviceSpec const>().forwards) {
372-
if (DataSpecUtils::match(forward.matcher, dh->dataOrigin, dh->dataDescription, dh->subSpecification)) {
373+
if (DataSpecUtils::match(forward.matcher, *dh)) {
373374
forwarded = true;
374375
break;
375376
}
@@ -378,8 +379,8 @@ o2::framework::ServiceSpec ArrowSupport::arrowBackendSpec()
378379
LOGP(debug, "Message {}/{} is forwarded so we are not returning its memory.", dh->dataOrigin, dh->dataDescription);
379380
continue;
380381
}
381-
LOGP(debug, "Message {}/{} is being deleted. We will return {}MB.", dh->dataOrigin, dh->dataDescription, dh->payloadSize / 1000000.);
382-
totalBytes += dh->payloadSize;
382+
LOGP(debug, "Message {}/{} is being deleted. We will return {}MB.", dh->dataOrigin, dh->dataDescription, payloadSize / 1000000.);
383+
totalBytes += payloadSize;
383384
totalMessages += 1;
384385
}
385386
arrow->updateBytesDestroyed(totalBytes);

0 commit comments

Comments
 (0)