/** * Start with ordinal selection of input stages then ordinal selection of each output ring there after. * TODO: do generic return that extends pronghornStage * @param m * @param path */ public static PronghornStage findStageByPath(GraphManager m, int ... path) { int ordinal = path[0]; int i = 0; int limit = m.stageIdToStage.length; while (i<limit) { if (null!=m.stageIdToStage[i]) { //an input stage is one that has no input ring buffers if (-1 == m.multInputIds[m.stageIdToInputsBeginIdx[m.stageIdToStage[i].stageId]]) { if (--ordinal<=0) { //starting from 1 find this path return findStageByPath(m, m.stageIdToStage[i], 1, path); } } } i++; } throw new UnsupportedOperationException("Unable to find ordinal input stage of "+path[0]); }
private static PronghornStage findStageByPath(GraphManager m, PronghornStage stage, int idx, int[] path) { if (idx>=path.length) { return stage; } return findStageByPath(m,getRingConsumer(m, getOutputPipe(m,stage,path[idx]).id),1+idx,path); }