diff options
| author | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
|---|---|---|
| committer | max42 <[email protected]> | 2023-06-30 11:13:34 +0300 |
| commit | 3e1899838408bbad47622007aa382bc8a2b01f87 (patch) | |
| tree | 0f21c1e6add187ddb6c3ccc048a7d640ce03fb87 /yt/cpp/mapreduce/interface/job_counters.cpp | |
| parent | 5463eb3f5e72a86f858a3d27c886470a724ede34 (diff) | |
Revert "YT-19324: move YT provider to ydb/library/yql"
This reverts commit ca272f12fdd0e8d5c3e957fc87939148f1caaf72, reversing
changes made to 49f8acfc8b0b5c0071b804423bcf53fda26c7c12.
Diffstat (limited to 'yt/cpp/mapreduce/interface/job_counters.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/interface/job_counters.cpp | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/yt/cpp/mapreduce/interface/job_counters.cpp b/yt/cpp/mapreduce/interface/job_counters.cpp deleted file mode 100644 index 6d4a2a6fcb3..00000000000 --- a/yt/cpp/mapreduce/interface/job_counters.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include "job_counters.h" - -namespace NYT { - -//////////////////////////////////////////////////////////////////// - -namespace { - ui64 CountTotal(const TNode& data) - { - if (data.IsMap()) { - if (auto totalPtr = data.AsMap().FindPtr("total")) { - return data["total"].IntCast<ui64>(); - } else { - ui64 total = 0; - for (const auto& keyVal: data.AsMap()) { - total += CountTotal(keyVal.second); - } - return total; - } - } else { - return data.IntCast<ui64>(); - } - } - - TNode GetNode(const TNode& data, const TStringBuf& key) - { - if (auto resPtr = data.AsMap().FindPtr(key)) { - return *resPtr; - } - return TNode(); - } -} // namespace - -//////////////////////////////////////////////////////////////////// - -TJobCounter::TJobCounter(TNode data) - : Data_(std::move(data)) -{ - if (Data_.HasValue()) { - Total_ = CountTotal(Data_); - } -} - -TJobCounter::TJobCounter(ui64 total) - : Total_(total) -{ } - -ui64 TJobCounter::GetTotal() const -{ - return Total_; -} - -ui64 TJobCounter::GetValue(const TStringBuf key) const -{ - if (Data_.HasValue()) { - return CountTotal(Data_[key]); - } - return 0; -} - -//////////////////////////////////////////////////////////////////// - -TJobCounters::TJobCounters(const NYT::TNode& counters) - : Total_(0) -{ - if (!counters.IsMap()) { - ythrow yexception() << "TJobCounters must be initialized with Map type TNode"; - } - auto abortedNode = GetNode(counters, "aborted"); - if (abortedNode.HasValue()) { - Aborted_ = TJobCounter(GetNode(abortedNode, "total")); - AbortedScheduled_ = TJobCounter(GetNode(abortedNode, "scheduled")); - AbortedNonScheduled_ = TJobCounter(GetNode(abortedNode, "non_scheduled")); - } - auto completedNode = GetNode(counters, "completed"); - if (completedNode.HasValue()) { - Completed_ = TJobCounter(GetNode(completedNode, "total")); - CompletedNonInterrupted_ = TJobCounter(GetNode(completedNode, "non-interrupted")); - CompletedInterrupted_ = TJobCounter(GetNode(completedNode, "interrupted")); - } - Lost_ = TJobCounter(GetNode(counters, "lost")); - Invalidated_ = TJobCounter(GetNode(counters, "invalidated")); - Failed_ = TJobCounter(GetNode(counters, "failed")); - Running_ = TJobCounter(GetNode(counters, "running")); - Suspended_ = TJobCounter(GetNode(counters, "suspended")); - Pending_ = TJobCounter(GetNode(counters, "pending")); - Blocked_ = TJobCounter(GetNode(counters, "blocked")); - Total_ = CountTotal(counters); -} - - -const TJobCounter& TJobCounters::GetAborted() const -{ - return Aborted_; -} - -const TJobCounter& TJobCounters::GetAbortedScheduled() const -{ - return AbortedScheduled_; -} - -const TJobCounter& TJobCounters::GetAbortedNonScheduled() const -{ - return AbortedNonScheduled_; -} - -const TJobCounter& TJobCounters::GetCompleted() const -{ - return Completed_; -} - -const TJobCounter& TJobCounters::GetCompletedNonInterrupted() const -{ - return CompletedNonInterrupted_; -} - -const TJobCounter& TJobCounters::GetCompletedInterrupted() const -{ - return CompletedInterrupted_; -} - -const TJobCounter& TJobCounters::GetLost() const -{ - return Lost_; -} - -const TJobCounter& TJobCounters::GetInvalidated() const -{ - return Invalidated_; -} - -const TJobCounter& TJobCounters::GetFailed() const -{ - return Failed_; -} - -const TJobCounter& TJobCounters::GetRunning() const -{ - return Running_; -} - -const TJobCounter& TJobCounters::GetSuspended() const -{ - return Suspended_; -} - -const TJobCounter& TJobCounters::GetPending() const -{ - return Pending_; -} - -const TJobCounter& TJobCounters::GetBlocked() const -{ - return Blocked_; -} - -ui64 TJobCounters::GetTotal() const -{ - return Total_; -} - -//////////////////////////////////////////////////////////////////// - -} // namespace NYT |
