16 #ifndef THRILL_API_DIA_BASE_HEADER 17 #define THRILL_API_DIA_BASE_HEADER 63 size_t limit()
const {
return limit_; }
66 bool is_max()
const {
return limit_ == max_limit_; }
69 operator size_t ()
const { assert(!is_max());
return limit_; }
76 static constexpr
size_t max_limit_ =
static_cast<size_t>(-1);
97 const std::initializer_list<size_t>& parent_ids,
98 const std::initializer_list<DIABasePtr>& parents)
99 : context_(ctx), dia_id_(ctx.next_dia_id()),
100 label_(label), parents_(parents) {
101 logger_ <<
"class" <<
"DIABase" 102 <<
"event" <<
"create" 104 <<
"parents" << parent_ids;
112 std::vector<size_t>&& parent_ids,
113 std::vector<DIABasePtr>&& parents)
114 : context_(ctx), dia_id_(ctx.next_dia_id()),
115 label_(
std::move(label)), parents_(
std::move(parents)) {
116 logger_ <<
"class" <<
"DIABase" 117 <<
"event" <<
"create" 119 <<
"parents" << parent_ids;
136 logger_ <<
"class" <<
"DIABase" 137 <<
"event" <<
"destroy" 138 <<
"parents" << parent_ids();
142 p->RemoveChild(
this);
179 virtual void Execute() = 0;
185 virtual void PushData(
bool consume) = 0;
195 virtual void RunPushData() = 0;
198 virtual std::vector<DIABase*> children()
const = 0;
201 virtual void RemoveChild(
DIABase* node) = 0;
205 virtual void RemoveAllChildren() = 0;
231 if (consume_counter_ == kNeverConsume)
return;
232 consume_counter_ += counter;
238 assert(consume_counter_ > 0);
239 if (consume_counter_ <= counter) {
240 consume_counter_ = 0;
243 consume_counter_ -= counter;
249 consume_counter_ = counter;
253 const std::vector<DIABasePtr>&
parents()
const {
259 std::vector<size_t> ids;
260 for (
const DIABasePtr& p : parents_) ids.push_back(p->dia_id());
268 parents_.begin(), parents_.end(),
269 [p](
const DIABasePtr& parent) {
return parent.get() == p; }),
279 return context_.mem_manager();
318 size_t consume_counter_ = 1;
324 static constexpr
size_t kNeverConsume =
static_cast<size_t>(-1);
330 &context_.
logger_,
"dia_id", dia_id(),
"label", label()
341 #endif // !THRILL_API_DIA_BASE_HEADER The DIABase has not been computed yet.
virtual void Dispose()
Virtual clear method. Triggers actual disposing in sub-classes.
std::vector< size_t > parent_ids() const
Returns the parents of this DIABase.
Description of the amount of RAM the internal data structures of a DIANode require.
Context & context()
Returns the api::Context of this DIABase.
const size_t dia_id_
DIA serial id.
virtual DIAMemUse ExecuteMemUse()
Amount of RAM used by Execute()
DIABase(Context &ctx, const char *label, const std::initializer_list< size_t > &parent_ids, const std::initializer_list< DIABasePtr > &parents)
The constructor for a DIABase.
virtual void DecConsumeCounter(size_t counter)
DIABase(Context &ctx, const char *label, std::vector< size_t > &&parent_ids, std::vector< DIABasePtr > &&parents)
The constructor for a DIABase.
A File is an ordered sequence of Block objects for storing items.
void set_mem_limit(const DIAMemUse &mem_limit)
const std::vector< DIABasePtr > & parents() const
Returns the parents of this DIABase.
size_t limit() const
return amount of RAM reserved
const char * label() const
return label() of DIANode subclass as stored by StatsNode
The Context of a job is a unique instance per worker which holds references to all underlying parts o...
virtual bool ForwardDataOnly() const
The DIABase is the untyped super class of DIANode.
virtual DIAMemUse PreOpMemUse()
Amount of RAM used by PreOp after StartPreOp()
const char *const label_
DOp node static label.
virtual ~DIABase()
Virtual destructor for a DIABase.
virtual size_t consume_counter() const
Returns consume_counter_.
bool is_max() const
test if sentinel for maximum RAM request
mem::Manager & mem_manager()
Return the Context's memory manager.
std::vector< DIABasePtr > parents_
Parents of this DIABase.
virtual void StopPreOp(size_t)
Virtual method for preparing end of PushData.
common::JsonLogger logger_
virtual void StartPreOp(size_t)
Virtual method for preparing start of PushData.
virtual void SetConsumeCounter(size_t counter)
const size_t & dia_id() const
return unique id of DIANode subclass as stored by StatsNode
void set_state(const DIAState &state)
DIAState
Possible states a DIABase can be in.
Object shared by allocators and other classes to track memory allocations.
void RemoveParent(DIABase *p)
Remove a parent.
virtual bool OnPreOpFile(const data::File &, size_t)
size_t limit_
amount of RAM requested or reserved.
JsonLogger is a receiver of JSON output objects for logging.
virtual void IncConsumeCounter(size_t counter)
DIAMemUse(size_t limit=0)
Implicit conversion of a size_t for a constant RAM usage request.
virtual bool RequireParentPushData(size_t) const
Context & context_
associated Context
Provides reference counting abilities for use with CountingPtr.
virtual DIAMemUse PushDataMemUse()
Amount of RAM used by PushData()
std::ostream & operator<<(std::ostream &os, const DIABase &d)
make ostream-able.