1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
#pragma once
#include "fwd.h"
#include "structured_table_formats.h"
#include "operation_preparer.h"
#include <yt/cpp/mapreduce/http/fwd.h>
#include <yt/cpp/mapreduce/interface/client.h>
#include <yt/cpp/mapreduce/interface/operation.h>
#include <yt/cpp/mapreduce/interface/retry_policy.h>
#include <util/generic/ptr.h>
#include <util/generic/vector.h>
namespace NYT::NDetail {
////////////////////////////////////////////////////////////////////////////////
class TOperation
: public IOperation
{
public:
class TOperationImpl;
public:
explicit TOperation(TClientPtr client);
TOperation(TOperationId id, TClientPtr client);
virtual const TOperationId& GetId() const override;
virtual TString GetWebInterfaceUrl() const override;
void OnPrepared();
void SetDelayedStartFunction(std::function<TOperationId()> start);
virtual void Start() override;
void OnPreparationException(std::exception_ptr e);
virtual bool IsStarted() const override;
virtual TString GetStatus() const override;
void OnStatusUpdated(const TString& newStatus);
virtual ::NThreading::TFuture<void> GetPreparedFuture() override;
virtual ::NThreading::TFuture<void> GetStartedFuture() override;
virtual ::NThreading::TFuture<void> Watch() override;
virtual TVector<TFailedJobInfo> GetFailedJobInfo(const TGetFailedJobInfoOptions& options = TGetFailedJobInfoOptions()) override;
virtual EOperationBriefState GetBriefState() override;
virtual TMaybe<TYtError> GetError() override;
virtual TJobStatistics GetJobStatistics() override;
virtual TMaybe<TOperationBriefProgress> GetBriefProgress() override;
virtual void AbortOperation() override;
virtual void CompleteOperation() override;
virtual void SuspendOperation(const TSuspendOperationOptions& options) override;
virtual void ResumeOperation(const TResumeOperationOptions& options) override;
virtual TOperationAttributes GetAttributes(const TGetOperationOptions& options) override;
virtual void UpdateParameters(const TUpdateOperationParametersOptions& options) override;
virtual TJobAttributes GetJob(const TJobId& jobId, const TGetJobOptions& options) override;
virtual TListJobsResult ListJobs(const TListJobsOptions& options) override;
private:
TClientPtr Client_;
::TIntrusivePtr<TOperationImpl> Impl_;
};
using TOperationPtr = ::TIntrusivePtr<TOperation>;
////////////////////////////////////////////////////////////////////////////////
struct TSimpleOperationIo
{
TVector<TRichYPath> Inputs;
TVector<TRichYPath> Outputs;
TFormat InputFormat;
TFormat OutputFormat;
TVector<TSmallJobFile> JobFiles;
};
TSimpleOperationIo CreateSimpleOperationIoHelper(
const IStructuredJob& structuredJob,
const TOperationPreparer& preparer,
const TOperationOptions& options,
TStructuredJobTableList structuredInputs,
TStructuredJobTableList structuredOutputs,
TUserJobFormatHints hints,
ENodeReaderFormat nodeReaderFormat,
const THashSet<TString>& columnsUsedInOperations);
////////////////////////////////////////////////////////////////////////////////
void ExecuteMap(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TMapOperationSpec& spec,
const ::TIntrusivePtr<IStructuredJob>& mapper,
const TOperationOptions& options);
void ExecuteRawMap(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TRawMapOperationSpec& spec,
const ::TIntrusivePtr<IRawJob>& mapper,
const TOperationOptions& options);
void ExecuteReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TReduceOperationSpec& spec,
const ::TIntrusivePtr<IStructuredJob>& reducer,
const TOperationOptions& options);
void ExecuteRawReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TRawReduceOperationSpec& spec,
const ::TIntrusivePtr<IRawJob>& reducer,
const TOperationOptions& options);
void ExecuteJoinReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TJoinReduceOperationSpec& spec,
const ::TIntrusivePtr<IStructuredJob>& reducer,
const TOperationOptions& options);
void ExecuteRawJoinReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TRawJoinReduceOperationSpec& spec,
const ::TIntrusivePtr<IRawJob>& reducer,
const TOperationOptions& options);
void ExecuteMapReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TMapReduceOperationSpec& spec,
const ::TIntrusivePtr<IStructuredJob>& mapper,
const ::TIntrusivePtr<IStructuredJob>& reduceCombiner,
const ::TIntrusivePtr<IStructuredJob>& reducer,
const TOperationOptions& options);
void ExecuteRawMapReduce(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TRawMapReduceOperationSpec& spec,
const ::TIntrusivePtr<IRawJob>& mapper,
const ::TIntrusivePtr<IRawJob>& reduceCombiner,
const ::TIntrusivePtr<IRawJob>& reducer,
const TOperationOptions& options);
void ExecuteSort(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TSortOperationSpec& spec,
const TOperationOptions& options);
void ExecuteMerge(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TMergeOperationSpec& spec,
const TOperationOptions& options);
void ExecuteErase(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TEraseOperationSpec& spec,
const TOperationOptions& options);
void ExecuteRemoteCopy(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TRemoteCopyOperationSpec& spec,
const TOperationOptions& options);
void ExecuteVanilla(
const TOperationPtr& operation,
const TOperationPreparerPtr& preparer,
const TVanillaOperationSpec& spec,
const TOperationOptions& options);
EOperationBriefState CheckOperation(
const IClientRetryPolicyPtr& clientRetryPolicy,
const TClientContext& context,
const TOperationId& operationId);
void WaitForOperation(
const IClientRetryPolicyPtr& clientRetryPolicy,
const IRawClientPtr& rawClient,
const TClientContext& context,
const TOperationId& operationId);
////////////////////////////////////////////////////////////////////////////////
::TIntrusivePtr<TOperation> ProcessOperation(
NYT::NDetail::TClientPtr client,
std::function<void()> prepare,
::TIntrusivePtr<TOperation> operation,
const TOperationOptions& options);
void WaitIfRequired(const TOperationPtr& operation, const TClientPtr& client, const TOperationOptions& options);
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NDetail
|