3.5.3. Predicates

Predicate

Operator

Output family length

\(\tilde{b} = \predicate{f}\ a\)

\(f: A \rightarrow \bool\)

\(|\tilde{b}| = |a|\)

The predicate HOF is a transform (see Section 3.5.1) whose operator returns Boolean true or false. However, instead of the framework interpreting the Boolean result as a data product, the return value is used to short-circuit the processing of the data-flow graph for data products that do not meet the specified criteria. This short-circuiting behavior is known as filtering and is described in Section 3.5.4.

Note that the output family generated by the predicate is the same length as the input family but with values that are either Boolean true or false. It is not until the predicate results are used by the filter that an input family is potentially reduced in length.

Note

Phlex will schedule a predicate HOF for execution only if it is included in a predicate expression (see Section 3.5.4).

3.5.3.1. Operator Signature

Operator

Allowed signature

\(f\)

bool function_name(P1, Pn..., Rm...) [quals];

3.5.3.2. Registration Interface

The workflow in Fig. 3.1 demonstrates a use of a predicate in the \(\textit{filter(high\_energy)}\) node, where the predicate is \(\textit{high\_energy}\) that operates on each \(\textit{GoodHits}\) data product. Although Fig. 3.1 does not include an explicit node for the \(\textit{high\_energy}\) predicate (for reasons of exposition), the predicate HOF does have its own node, which is then bound to one or more filters via predicate expressions. The registration for the predicate node in Fig. 3.1 would look like:

class hits { ... };
bool high_energy(hits const& hs) { ... }

PHLEX_REGISTER_ALGORITHMS(config)
{
  predicate("high_energy", high_energy, concurrency::unlimited)
    .family("GoodHits"_in("APA"));
}