13 #ifndef THRILL_API_COLLAPSE_HEADER 14 #define THRILL_API_COLLAPSE_HEADER 28 template <
typename ValueType>
38 template <
typename ParentDIA>
40 :
Super(parent.ctx(),
"Collapse", { parent.id() }, { parent.node() }),
42 auto propagate_fn = [
this](
const ValueType& input) {
45 auto lop_chain = parent.stack().push(propagate_fn).fold();
46 parent.node()->AddChild(
this, lop_chain);
59 child.node->StartPreOp(child.parent_index);
66 <<
"Collapse rejected File from parent " 67 <<
"due to non-empty function stack.";
73 <<
"Collapse accepted File from parent";
81 child.node->StopPreOp(child.parent_index);
90 c =
std::min(c, p->consume_counter());
98 p->IncConsumeCounter(consume);
105 p->DecConsumeCounter(consume);
112 p->SetConsumeCounter(consume);
121 #ifndef THRILL_DOXYGEN_IGNORE 123 template <
typename ValueType,
typename Stack>
124 template <
typename AnyStack>
129 LOG0 <<
"WARNING: cast to DIA creates CollapseNode instead of inline chaining.";
130 LOG0 <<
"Consider whether you can use auto instead of DIA.";
133 #endif // THRILL_DOXYGEN_IGNORE 136 template <
typename ValueType,
typename Stack>
150 template <
typename ValueType>
158 template <
typename ValueType,
typename Stack>
166 #endif // !THRILL_API_COLLAPSE_HEADER bool ForwardDataOnly() const final
A CollapseNode cannot be executed, it never contains any data.
Template switch to generate a CollapseNode if there is a non-empty Stack.
const bool parent_stack_empty_
Whether the parent stack is empty.
DIA is the interface between the user and the Thrill framework.
void PushItem(const ValueType &item) const
Method for derived classes to Push a single item to all children.
bool IsValid() const
Return whether the DIA is valid.
void SetConsumeCounter(size_t consume) final
void DecConsumeCounter(size_t consume) final
A File is an ordered sequence of Block objects for storing items.
bool OnPreOpFile(const data::File &file, size_t) final
Receive a whole data::File of ValueType, but only if our stack is empty.
#define LOG0
Override default output: never or always output log.
DIA()=default
default-constructor: invalid DIA
void Execute() final
Virtual execution method. Triggers actual computation in sub-classes.
size_t consume_counter() const final
Returns consume_counter_.
A DIANode is a typed node representing and operation in Thrill.
void StartPreOp(size_t) final
Virtual method for preparing start of PushData.
A FunctionStack is a chain of functor that can be folded to a single functor (which is usually optimi...
CollapseNode(const ParentDIA &parent)
Constructor for a LOpNode.
static DIA< ValueType > MakeCollapse(const DIA< ValueType, Stack > &dia)
std::vector< DIABasePtr > parents_
Parents of this DIABase.
bool RequireParentPushData(size_t) const final
CountingPtr< Type > make_counting(Args &&... args)
method analogous to std::make_shared and std::make_unique.
static DIA< ValueType > MakeCollapse(const DIA< ValueType, tlx::FunctionStack< ValueType > > &dia)
void IncConsumeCounter(size_t consume) final
size_t my_rank() const
Global rank of this worker among all other workers in the system.
static uint_pair min()
return an uint_pair instance containing the smallest value possible
std::vector< Child > children_
Callback functions from the child nodes.
File Copy() const
Return a copy of the File (explicit copy-constructor)
void StopPreOp(size_t) final
Virtual method for preparing end of PushData.
void PushData(bool) final
Virtual method for pushing data. Triggers actual pushing in sub-classes.
void PushFile(data::File &file, bool consume) const
static constexpr size_t kNeverConsume
Never full consume.
Context & context_
associated Context
DIA< ValueType > Collapse() const
Create a CollapseNode which is mainly used to collapse the LOp chain into a DIA<T> with an empty stac...
#define LOGC(cond)
Explicitly specify the condition for logging.