11#ifndef FRAMEWORK_UTILS_DPLRAWPAGESEQUENCER_H
12#define FRAMEWORK_UTILS_DPLRAWPAGESEQUENCER_H
77 template <
typename Predicate,
typename Inserter,
typename Precheck>
78 int operator()(Predicate&& pred, Inserter&& inserter, Precheck preCheck)
80 return binary(std::forward<Predicate>(pred), std::forward<Inserter>(inserter), std::forward<Precheck>(preCheck));
83 template <
typename Predicate,
typename Inserter>
86 return binary(std::forward<Predicate>(pred), std::forward<Inserter>(inserter), [](...) {
return true; });
89 template <
typename Predicate,
typename Inserter>
90 int binary(Predicate pred, Inserter inserter)
92 return binary(std::forward<Predicate>(pred), std::forward<Inserter>(inserter), [](...) {
return true; });
95 template <
typename Predicate,
typename Inserter,
typename Precheck>
96 int binary(Predicate pred, Inserter inserter, Precheck preCheck)
99 for (
auto const&
ref : mInput) {
101 const auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
106 if (dh->subSpecification == 0xDEADBEEF) {
112 auto nPages =
size / pageSize + (
size % pageSize ? 1 : 0);
113 if (!preCheck(
ref.payload, dh->subSpecification)) {
117 const char* iterator =
ref.payload;
119 auto check = [&pred, &pageSize, payload =
ref.payload](
size_t left,
size_t right) ->
bool {
120 return pred(payload +
left * pageSize, payload +
right * pageSize);
122 auto insert = [&inserter, &pageSize, payload =
ref.payload](
size_t pos,
size_t n, uint32_t subSpec) ->
void {
123 inserter(payload +
pos * pageSize,
n, subSpec);
130 auto step =
count / 2;
148 forwardInternal(std::forward<Predicate>(pred), std::forward<Inserter>(inserter),
ref.payload,
size, dh);
156 if (
check(p, nPages - 1)) {
157 insert(p, nPages - p, dh->subSpecification);
160 auto q =
search(p, nPages - p);
161 insert(p, q - p, dh->subSpecification);
163 }
while (p < nPages);
170 template <
typename Predicate,
typename Inserter>
171 int forward(Predicate pred, Inserter inserter)
173 return forward(std::forward<Predicate>(pred), std::forward<Inserter>(inserter), [](...) {
return true; });
176 template <
typename Predicate,
typename Inserter,
typename Precheck>
177 int forward(Predicate pred, Inserter inserter, Precheck preCheck)
179 for (
auto const&
ref : mInput) {
184 auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
185 if (!preCheck(
ref.payload, dh->subSpecification)) {
188 forwardInternal(std::forward<Predicate>(pred), std::forward<Inserter>(inserter),
ref.payload,
size, dh);
196 template <
typename Predicate,
typename Inserter>
200 const char*
ptr =
nullptr;
202 for (
auto it = parser.begin(); it != parser.end(); it++) {
203 const char* current =
reinterpret_cast<const char*
>(it.raw());
204 if (
ptr ==
nullptr) {
206 }
else if (pred(
ptr, current) ==
false) {
Generic parser for consecutive raw pages.
This utility handles transparently the DPL inputs and triggers a customizable action on sequences of ...
typename rawparser_type::buffer_type buffer_type
int binary(Predicate pred, Inserter inserter)
DPLRawPageSequencer()=delete
DPLRawPageSequencer(InputRecord &inputs, std::vector< InputSpec > filterSpecs={})
int operator()(Predicate &&pred, Inserter &&inserter)
int forward(Predicate pred, Inserter inserter, Precheck preCheck)
int binary(Predicate pred, Inserter inserter, Precheck preCheck)
int forward(Predicate pred, Inserter inserter)
int operator()(Predicate &&pred, Inserter &&inserter, Precheck preCheck)
unsigned char buffer_type
static size_t const max_size
const GLuint GLenum const void * binary
Defining PrimaryVertex explicitly as messageable.
void check(const std::vector< std::string > &arguments, const std::vector< ConfigParamSpec > &workflowOptions, const std::vector< DeviceSpec > &deviceSpecs, CheckMatrix &matrix)
bool search(DeviceExecution const &execution, std::string const &option, std::string const &argument)
static o2::header::DataHeader::PayloadSizeType getPayloadSize(const DataRef &ref)
static void warnDeadBeef(const o2::header::DataHeader *dh)
static bool checkRDH(const RDHv4 &rdh, bool verbose=true, bool checkZeros=false)