private void verifyCoGrouper() { if( isJoin() && joiner instanceof BufferJoin ) throw new IllegalArgumentException( "invalid joiner, may not use BufferJoiner in a HashJoin" ); if( joiner == null ) { joiner = new InnerJoin(); return; } if( joiner.numJoins() == -1 ) return; int joins = Math.max( numSelfJoins, keyFieldsMap.size() - 1 ); // joining two streams is one join if( joins != joiner.numJoins() ) throw new IllegalArgumentException( "invalid joiner, only accepts " + joiner.numJoins() + " joins, there are: " + joins ); }
@Override public String getName() { if( spliceName != null ) return spliceName; StringBuffer buffer = new StringBuffer(); for( Pipe pipe : pipes ) { if( buffer.length() != 0 ) { if( isGroupBy() || isMerge() ) buffer.append( "+" ); else if( isCoGroup() || isJoin() ) buffer.append( "*" ); // more semantically correct } buffer.append( pipe.getName() ); } spliceName = buffer.toString(); return spliceName; }
private void setOrdinal( FlowElement previous, Pipe current, Scope scope ) { if( current instanceof Splice ) { Splice splice = (Splice) current; Integer ordinal; if( previous instanceof Tap ) // revert to pipe name ordinal = splice.getPipePos().get( scope.getName() ); else // GroupBy allows for duplicate pipe names, this guarantees correct ordinality ordinal = FlowElements.findOrdinal( splice, (Pipe) previous ); scope.setOrdinal( ordinal ); Set<Scope> scopes = new HashSet<>( incomingEdgesOf( current ) ); scopes.remove( scope ); for( Scope other : scopes ) { if( other.getOrdinal() == scope.getOrdinal() ) throw new IllegalStateException( "duplicate ordinals" ); } if( splice.isJoin() && ordinal != 0 ) scope.setNonBlocking( false ); } }
boolean isJoin = flowElement instanceof Splice && ( (Splice) flowElement ).isJoin();
public static void insertFlowElementBetweenEdge( ElementGraph elementGraph, Scope previousEdge, FlowElement newElement ) { FlowElement previousElement = elementGraph.getEdgeSource( previousEdge ); FlowElement nextElement = elementGraph.getEdgeTarget( previousEdge ); elementGraph.addVertex( newElement ); // add edge between previous and new elementGraph.addEdge( previousElement, newElement, new Scope( previousEdge ) ); // add edge between new and next Scope scope = new Scope( previousEdge ); scope.setOrdinal( previousEdge.getOrdinal() ); if( nextElement instanceof Splice && ( (Splice) nextElement ).isJoin() && previousEdge.getOrdinal() != 0 ) scope.setNonBlocking( false ); elementGraph.addEdge( newElement, nextElement, scope ); // remove previous edge elementGraph.removeEdge( previousElement, nextElement ); }