@Override public void initialize() { super.initialize(); aggregator = every.getAggregator(); outputCollector = new TupleEntryCollector( getOperationDeclaredFields() ) { @Override protected void collect( TupleEntry resultEntry ) throws IOException { Tuple outgoing = outgoingBuilder.makeResult( incomingEntry.getTuple(), resultEntry.getTuple() ); outgoingEntry.setTuple( outgoing ); try { reducing.completeGroup( AggregatorEveryStage.this, outgoingEntry ); } finally { Tuples.asModifiable( outgoing ); } } }; reducing = (Reducing) getNext(); }
@Override public void completeGroup( Duct previous, TupleEntry incomingEntry ) { this.incomingEntry = incomingEntry; operationCall.setArguments( null ); operationCall.setOutputCollector( outputCollector ); try { aggregator.complete( flowProcess, operationCall ); // collector calls next } catch( CascadingException exception ) { handleException( exception, incomingEntry ); } catch( Throwable throwable ) { handleException( new OperatorException( every, "operator Every failed completing operation: " + every.getOperation(), throwable ), incomingEntry ); } } }
rhsDuct = new BufferEveryWindow( flowProcess, everyElement ); else if( everyElement.isAggregator() ) rhsDuct = new AggregatorEveryStage( flowProcess, everyElement ); else if( everyElement.isGroupAssertion() ) rhsDuct = new GroupAssertionEveryStage( flowProcess, everyElement );
@Override public void startGroup( Duct previous, TupleEntry groupEntry ) { operationCall.setGroup( groupEntry ); operationCall.setArguments( null ); // zero it out operationCall.setOutputCollector( null ); // zero it out try { aggregator.start( flowProcess, operationCall ); } catch( CascadingException exception ) { handleException( exception, groupEntry ); } catch( Throwable throwable ) { handleException( new OperatorException( every, "operator Every failed starting operation: " + every.getOperation(), throwable ), groupEntry ); } reducing.startGroup( this, groupEntry ); }
@Override public void receive( Duct previous, int ordinal, TupleEntry tupleEntry ) { try { argumentsEntry.setTuple( argumentsBuilder.makeResult( tupleEntry.getTuple(), null ) ); operationCall.setArguments( argumentsEntry ); aggregator.aggregate( flowProcess, operationCall ); } catch( CascadingException exception ) { handleException( exception, argumentsEntry ); } catch( Throwable throwable ) { handleException( new OperatorException( every, "operator Every failed executing operation: " + every.getOperation(), throwable ), argumentsEntry ); } next.receive( this, ordinal, tupleEntry ); }