* @param block ステージブロック
* @return シャッフルの構造、シャッフルしない場合は{@code null}
* @throws IOException 出力に失敗した場合
*/
protected ShuffleModel compileShuffle(StageBlock block) throws IOException {
ShuffleModel shuffle = new ShuffleAnalyzer(environment).analyze(block);
assertThat(environment.hasError(), is(false));
if (shuffle == null) {
return null;
}
Name keyTypeName = new ShuffleKeyEmitter(environment).emit(shuffle);
Name valueTypeName = new ShuffleValueEmitter(environment).emit(shuffle);
Name groupComparatorTypeName = new ShuffleGroupingComparatorEmitter(environment).emit(shuffle, keyTypeName);
Name sortComparatorTypeName = new ShuffleSortComparatorEmitter(environment).emit(shuffle, keyTypeName);
Name partitionerTypeName = new ShufflePartitionerEmitter(environment).emit(shuffle, keyTypeName, valueTypeName);
CompiledShuffle compiled = new CompiledShuffle(
keyTypeName,
valueTypeName,
groupComparatorTypeName,
sortComparatorTypeName,
partitionerTypeName);
shuffle.setCompiled(compiled);
return shuffle;
}