14 #ifndef THRILL_API_ZIP_WITH_INDEX_HEADER 15 #define THRILL_API_ZIP_WITH_INDEX_HEADER 37 template <
typename ValueType,
typename ZipFunction>
40 static constexpr
bool debug =
false;
46 typename common::FunctionTraits<ZipFunction>::template arg_plain<0>;
52 template <
typename ParentDIA>
54 const ZipFunction& zip_function,
const ParentDIA& parent)
55 :
Super(parent.ctx(),
"ZipWithIndex",
56 { parent.id() }, { parent.node() }),
60 auto pre_op_fn = [
this](
const InputType& input) {
64 auto lop_chain = parent.stack().push(pre_op_fn).fold();
65 parent.node()->AddChild(
this, lop_chain);
72 <<
"ZipWithIndex rejected File from parent due to Stack";
89 sLOG <<
"dia_local_size" << dia_local_size;
108 "Zip() result_count", result_count);
138 template <
typename ValueType,
typename Stack>
139 template <
typename ZipFunction>
141 const ZipFunction& zip_function)
const {
144 common::FunctionTraits<ZipFunction>::arity == 2,
145 "ZipWithIndexFunction must take exactly two parameters");
150 typename common::FunctionTraits<ZipFunction>::template arg<0>
152 "ZipWithIndexFunction has the wrong input type in DIA 0");
157 typename common::FunctionTraits<ZipFunction>::template arg<1>
159 "ZipWithIndexFunction must take a const unsigned long int& (aka. size_t)" 160 " as second parameter");
163 =
typename common::FunctionTraits<ZipFunction>::result_type;
167 auto node = tlx::make_counting<ZipWithIndexNode>(zip_function, *
this);
177 #endif // !THRILL_API_ZIP_WITH_INDEX_HEADER const bool parent_stack_empty_
Whether the parent stack is empty.
net::FlowControlChannel & net
#define sLOG
Default logging method: output if the local debug variable is true.
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.
void PrintCollectiveMeanStdev(const char *text, const Type &local)
A File is an ordered sequence of Block objects for storing items.
void Clear()
Free all Blocks in the File and deallocate vectors.
bool OnPreOpFile(const data::File &file, size_t) final
Receive a whole data::File of ValueType, but only if our stack is empty.
size_t dia_local_rank_
exclusive prefix sum over the number of items in workers
typename common::FunctionTraits< ZipFunction >::template arg_plain< 0 > InputType
T TLX_ATTRIBUTE_WARN_UNUSED_RESULT ExPrefixSum(const T &value, const BinarySumOp &sum_op=BinarySumOp(), const T &initial=T())
Calculates the exclusive prefix sum over all workers, given a certain sum operation.
void StopPreOp(size_t) final
Virtual method for preparing end of PushData.
BlockWriter contains a temporary Block object into which a) any serializable item can be stored or b)...
static constexpr bool g_debug_push_file
void Execute() final
Virtual execution method. Triggers actual computation in sub-classes.
data::File::Writer writer_
Writer to intermediate file.
BlockReader takes Block objects from BlockSource and allows reading of a) serializable Items or b) ar...
ZipWithIndexNode(const ZipFunction &zip_function, const ParentDIA &parent)
Constructor for a ZipNode.
data::File file_
File for intermediate storage.
static constexpr bool debug
auto ZipWithIndex(const ZipFunction &zip_function) const
Zips each item of a DIA with its zero-based array index.
data::File GetFile(size_t dia_id)
Returns a new File object containing a sequence of local Blocks.
void PushData(bool consume) final
Virtual method for pushing data. Triggers actual pushing in sub-classes.
A DOpNode is a typed node representing and distributed operations in Thrill.
Reader GetReader(bool consume, size_t prefetch_size=File::default_prefetch_size_)
Get BlockReader or a consuming BlockReader for beginning of File.
ZipFunction zip_function_
Zip function.
void Dispose() final
Virtual clear method. Triggers actual disposing in sub-classes.
File Copy() const
Return a copy of the File (explicit copy-constructor)
TLX_ATTRIBUTE_ALWAYS_INLINE BlockWriter & Put(const T &x)
Put appends a complete item, or fails with a FullException.
size_t num_items() const
Return the number of items in the file.
void Close()
Explicitly close the writer.
TLX_ATTRIBUTE_ALWAYS_INLINE bool HasNext()
HasNext() returns true if at least one more item is available.
A DIANode which calculates the array index for each items and performs a Zip-like operation without e...
Writer GetWriter(size_t block_size=default_block_size)
Get BlockWriter.
Context & context_
associated Context
#define LOGC(cond)
Explicitly specify the condition for logging.