@Test public void testProcessRow() throws KettleException { AggregateRows aggregateRows = new AggregateRows( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); aggregateRows.init( stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface ); aggregateRows.setInputRowSets( new ArrayList<RowSet>( Arrays.asList( createSourceRowSet( "TEST" ) ) ) ); int fieldSize = stepMockHelper.initStepMetaInterface.getFieldName().length; AggregateRowsData data = new AggregateRowsData(); data.fieldnrs = new int[ fieldSize ]; data.counts = new long[ fieldSize ]; data.values = new Object[ fieldSize ]; assertTrue( aggregateRows.processRow( stepMockHelper.initStepMetaInterface, data ) ); assertTrue( aggregateRows.getErrors() == 0 ); assertTrue( aggregateRows.getLinesRead() > 0 ); RowMetaInterface outputRowMeta = mock( RowMetaInterface.class ); when( outputRowMeta.size() ).thenReturn( fieldSize ); data.outputRowMeta = outputRowMeta; assertFalse( aggregateRows.processRow( stepMockHelper.initStepMetaInterface, data ) ); assertTrue( aggregateRows.getLinesWritten() > 0 ); }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (AggregateRowsMeta) smi; data = (AggregateRowsData) sdi; Object[] r = getRow(); if ( r == null ) { Object[] agg = buildAggregate(); putRow( data.outputRowMeta, agg ); setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] ); if ( data.fieldnrs[i] < 0 ) { logError( BaseMessages.getString( PKG, "AggregateRows.Log.CouldNotFindField", meta.getFieldName()[i] ) ); setErrors( 1 ); stopAll(); return false; } data.counts[i] = 0L; } } AddAggregate( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "AggregateRows.Log.LineNumber" ) + getLinesRead() ); } } return true; }
AggregateRows extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (AggregateRowsMeta) smi; data = (AggregateRowsData) sdi; Object[] r = getRow(); if ( r == null ) { Object[] agg = buildAggregate(); putRow( data.outputRowMeta, agg ); setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] ); if ( data.fieldnrs[i] < 0 ) { logError( BaseMessages.getString( PKG, "AggregateRows.Log.CouldNotFindField", meta.getFieldName()[i] ) ); setErrors( 1 ); stopAll(); return false; } data.counts[i] = 0L; } } AddAggregate( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "AggregateRows.Log.LineNumber" ) + getLinesRead() ); } } return true; } }
AggregateRows extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (AggregateRowsMeta) smi; data = (AggregateRowsData) sdi; Object[] r = getRow(); if ( r == null ) { Object[] agg = buildAggregate(); putRow( data.outputRowMeta, agg ); setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] ); if ( data.fieldnrs[i] < 0 ) { logError( BaseMessages.getString( PKG, "AggregateRows.Log.CouldNotFindField", meta.getFieldName()[i] ) ); setErrors( 1 ); stopAll(); return false; } data.counts[i] = 0L; } } AddAggregate( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "AggregateRows.Log.LineNumber" ) + getLinesRead() ); } } return true; } AggregateRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
AggregateRows extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (AggregateRowsMeta) smi; data = (AggregateRowsData) sdi; Object[] r = getRow(); if ( r == null ) { Object[] agg = buildAggregate(); putRow( data.outputRowMeta, agg ); setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] ); if ( data.fieldnrs[i] < 0 ) { logError( BaseMessages.getString( PKG, "AggregateRows.Log.CouldNotFindField", meta.getFieldName()[i] ) ); setErrors( 1 ); stopAll(); return false; } data.counts[i] = 0L; } } AddAggregate( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "AggregateRows.Log.LineNumber" ) + getLinesRead() ); } } return true; } AggregateRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); }
AggregateRows extends BaseStep implements StepInterface { public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (AggregateRowsMeta) smi; data = (AggregateRowsData) sdi; Object[] r = getRow(); if ( r == null ) { Object[] agg = buildAggregate(); putRow( data.outputRowMeta, agg ); setOutputDone(); return false; } if ( first ) { first = false; data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); for ( int i = 0; i < meta.getFieldName().length; i++ ) { data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] ); if ( data.fieldnrs[i] < 0 ) { logError( BaseMessages.getString( PKG, "AggregateRows.Log.CouldNotFindField", meta.getFieldName()[i] ) ); setErrors( 1 ); stopAll(); return false; } data.counts[i] = 0L; } } AddAggregate( getInputRowMeta(), r ); if ( checkFeedback( getLinesRead() ) ) { if ( log.isBasic() ) { logBasic( BaseMessages.getString( PKG, "AggregateRows.Log.LineNumber" ) + getLinesRead() ); } } return true; } AggregateRows( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi );  }