MCPcopy Create free account
hub / github.com/catboost/catboost / RemoteMapReduceImpl

Function RemoteMapReduceImpl

library/cpp/par/par_util.cpp:115–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114 const int N_MAX_PART_COUNT = 100;
115 static void RemoteMapReduceImpl(TJobDescription* job, IDistrCmd* finalMap, ERROp op) {
116 CHROMIUM_TRACE_FUNCTION();
117
118 TObj<IDistrCmd> hold(finalMap);
119 if (job->ExecList.empty())
120 return;
121
122 int jobCount = job->ExecList.ysize();
123 int partCount = Min(jobCount, N_MAX_PART_COUNT);
124 int jobPerPart = (jobCount + partCount - 1) / partCount;
125
126 TVector<bool> hasData;
127 hasData.resize(jobCount);
128
129 TJobDescription newJob;
130 {
131 newJob.Cmds.resize(1);
132 TObj<TRemoteReduce> rr = new TRemoteReduce(finalMap, op);
133 SerializeToMem(&newJob.Cmds[0], rr);
134 }
135 newJob.ExecList.resize(partCount);
136
137 for (int part = 0; part < partCount; ++part) {
138 int startIdx = part * jobPerPart;
139 int finishIdx = Min(startIdx + jobPerPart, jobCount);
140 if (finishIdx <= startIdx) {
141 newJob.ExecList.resize(part);
142 break;
143 }
144 TJobDescription descr;
145 TVector<int> resultMap;
146 ProjectJob(&descr, startIdx, finishIdx - startIdx, &resultMap, &hasData, *job);
147 int paramId = newJob.AddParam(&descr);
148 TJobParams& jp = newJob.ExecList[part];
149 jp = TJobParams(0, paramId, part, -1, TJobDescription::ANYWHERE_HOST_ID);
150 }
151 job->Swap(&newJob);
152#ifdef _DEBUG
153 for (int i = 0; i < hasData.ysize(); ++i)
154 Y_ASSERT(hasData[i]);
155#endif
156 }
157
158 void RemoteMap(TJobDescription* job, IDistrCmd* finalMap) {
159 CHROMIUM_TRACE_FUNCTION();

Callers 2

RemoteMapFunction · 0.85
RemoteMapReduceFunction · 0.85

Calls 9

SerializeToMemFunction · 0.85
ProjectJobFunction · 0.85
TJobParamsClass · 0.85
AddParamMethod · 0.80
MinFunction · 0.50
emptyMethod · 0.45
ysizeMethod · 0.45
resizeMethod · 0.45
SwapMethod · 0.45

Tested by

no test coverage detected