private StageGraph flowToStageGraph(FlowGraph flowGraph) {
   assert flowGraph != null;
   StagePlanner planner =
       new StagePlanner(environment.getGraphRewriters().getRewriters(), environment.getOptions());
   StageGraph planned = planner.plan(flowGraph);
   assertThat(planner.getDiagnostics().toString(), planner.getDiagnostics().isEmpty(), is(true));
   return planned;
 }
 /**
  * Initializes the test.
  *
  * @throws Exception if some errors were occurred
  */
 @Before
 public void setUp() throws Exception {
   packager = new VolatilePackager();
   FlowCompilerConfiguration config = new FlowCompilerConfiguration();
   config.setBatchId("batch");
   config.setFlowId("flow");
   config.setFactory(Models.getModelFactory());
   config.setProcessors(new SpiFlowElementProcessorRepository());
   config.setExternals(new SpiExternalIoDescriptionProcessorRepository());
   config.setDataClasses(new SpiDataClassRepository());
   config.setGraphRewriters(new SpiFlowGraphRewriterRepository());
   config.setPackager(packager);
   config.setRootPackageName("com.example");
   config.setRootLocation(Location.fromPath("com/example", '/'));
   config.setServiceClassLoader(getClass().getClassLoader());
   config.setOptions(new FlowCompilerOptions());
   environment = new FlowCompilingEnvironment(config);
   environment.bless();
 }
 /**
  * ステージブロックを解析してシャッフルの構造を返す。
  *
  * @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;
 }