@Override public boolean applies( PlannerContext plannerContext, ElementGraph elementGraph, FlowElement flowElement ) { return super.applies( plannerContext, elementGraph, flowElement ) && !( (Splice) flowElement ).isSelfJoin(); } },
@Override public boolean applies( PlannerContext plannerContext, ElementGraph elementGraph, FlowElement flowElement ) { return super.applies( plannerContext, elementGraph, flowElement ) && !( (Splice) flowElement ).isSelfJoin(); } },
@Override public String toString() { StringBuilder buffer = new StringBuilder( super.toString() ); buffer.append( "[by:" ); for( String name : keyFieldsMap.keySet() ) { if( keyFieldsMap.size() > 1 ) buffer.append( " " ).append( name ).append( ":" ); buffer.append( keyFieldsMap.get( name ).printVerbose() ); } if( isSelfJoin() ) buffer.append( "[numSelfJoins:" ).append( numSelfJoins ).append( "]" ); buffer.append( "]" ); return buffer.toString(); }
@Override protected void printInternal( StringBuffer buffer, Scope scope ) { super.printInternal( buffer, scope ); Map<String, Fields> map = scope.getKeySelectors(); if( map != null ) { buffer.append( "[by:" ); // important to retain incoming pipe order for( Map.Entry<String, Fields> entry : keyFieldsMap.entrySet() ) { String name = entry.getKey(); if( map.size() > 1 ) buffer.append( name ).append( ":" ); Fields keys = map.get( name ); // if keys null, this is likely an edge contracted map if( keys == null ) buffer.append( "<unavailable>" ); else buffer.append( keys.print() ); // get resolved keys } if( isSelfJoin() ) buffer.append( "[numSelfJoins:" ).append( numSelfJoins ).append( "]" ); buffer.append( "]" ); } } }
private List<DataSet<Tuple>> computeSpliceInputsFieldsKeys(Splice splice, FlowNode node, List<DataSet<Tuple>> inputs, Fields[] inputFields, Fields[] keyFields, String[][] flinkKeys) { int numJoinInputs = splice.isSelfJoin() ? splice.getNumSelfJoins() + 1 : inputs.size(); List<Scope> inScopes = getInputScopes(node, splice); List<DataSet<Tuple>> inputs2; if(!splice.isSelfJoin()) {
@Override public void prepare() { int numJoinInputs = this.splice.isSelfJoin() ? this.splice.getNumSelfJoins() + 1 : this.splice.getPrevious().length; Fields[] keyFields = new Fields[numJoinInputs]; Fields[] valueFields = new Fields[numJoinInputs]; Scope outgoingScope = outgoingScopes.get( 0 ); if(!this.splice.isSelfJoin()) { for(int i=0; i < numJoinInputs; i++) { Scope incomingScope = incomingScopes.get( i ); int ordinal = incomingScope.getOrdinal(); keyFields[ordinal] = outgoingScope.getKeySelectors().get(incomingScope.getName()); valueFields[ordinal] = incomingScope.getIncomingSpliceFields(); } } else { Scope incomingScope = incomingScopes.get(0); keyFields[0] = outgoingScope.getKeySelectors().get(incomingScope.getName()); valueFields[0] = incomingScope.getIncomingSpliceFields(); for (int i = 1; i < numJoinInputs; i++) { keyFields[i] = keyFields[0]; valueFields[i] = valueFields[0]; } } this.closure = new JoinClosure(this.flowProcess, keyFields, valueFields); this.joiner = this.splice.getJoiner(); this.entryIterator = new TupleEntryChainIterator(outgoingScope.getOutValuesFields()); }
@Override public void prepare() { if( role != IORole.source ) { throw new UnsupportedOperationException("Non-source group by not supported in GroupByInGate"); } if( role != IORole.sink ) { Fields[] keyFields; Fields[] valuesFields; if(splice.isSelfJoin()) { keyFields = new Fields[splice.getNumSelfJoins() + 1]; valuesFields = new Fields[splice.getNumSelfJoins() + 1]; for(int i=0; i<keyFields.length; i++) { keyFields[i] = super.keyFields[0]; valuesFields[i] = super.valuesFields[0]; } } else { keyFields = super.keyFields; valuesFields = super.valuesFields; } closure = new JoinClosure(flowProcess, keyFields, valuesFields); } if( grouping != null && splice.getJoinDeclaredFields() != null && splice.getJoinDeclaredFields().isNone() ) { grouping.joinerClosure = closure; } this.resultIterator = new JoinResultIterator(closure, this.splice.getJoiner()); }
if( incomingScopes.size() != pipes.size() && isSelfJoin() ) throw new OperatorException( this, "self joins without intermediate operators are not permitted, see 'numSelfJoins' constructor or identity function" ); if( isSelfJoin() ) throw new OperatorException( this, "declared grouped fields not same size as grouped values, declared: " + declaredFields.printVerbose() + " != size: " + size * ( numSelfJoins + 1 ) ); else