| 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(); |
no test coverage detected