本文整理汇总了Java中org.pentaho.di.trans.RowProducer.putRow方法的典型用法代码示例。如果您正苦于以下问题:Java RowProducer.putRow方法的具体用法?Java RowProducer.putRow怎么用?Java RowProducer.putRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.trans.RowProducer
的用法示例。
在下文中一共展示了RowProducer.putRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeHexTest
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
/**
* Create, execute, and return the row listener attached to the output step with complete results from the
* execution.
*
* @param checkSumType Type of checksum to use (the array index of {@link CheckSumMeta#checksumtypeCodes})
* @param compatibilityMode Use compatibility mode for CheckSum
* @param input String to calculate checksum for
* @return RowListener with results.
*/
private MockRowListener executeHexTest(int checkSumType, boolean compatibilityMode, String input) throws Exception {
Trans trans = buildHexadecimalChecksumTrans(checkSumType, compatibilityMode);
trans.prepareExecution(null);
StepInterface output = trans.getRunThread("Output", 0); //$NON-NLS-1$
MockRowListener listener = new MockRowListener();
output.addRowListener(listener);
RowProducer rp = trans.addRowProducer("CheckSum", 0); //$NON-NLS-1$
RowMeta inputRowMeta = createStringRowMeta();
((BaseStep) trans.getRunThread("CheckSum", 0)).setInputRowMeta(inputRowMeta); //$NON-NLS-1$
trans.startThreads();
rp.putRow(inputRowMeta, new Object[] { input });
rp.finished();
trans.waitUntilFinished();
trans.stopAll();
trans.cleanup();
return listener;
}
示例2: injectValue
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void injectValue( Object key, int keyOrdinal, ITypeConverter inConverterK, Object value, int valueOrdinal,
ITypeConverter inConverterV, RowMeta injectorRowMeta, RowProducer rowProducer,
Reporter reporter )
throws Exception {
Object[] row = new Object[ injectorRowMeta.size() ];
row[ keyOrdinal ] =
inConverterK != null ? inConverterK.convert( injectorRowMeta.getValueMeta( keyOrdinal ), key ) : key;
row[ valueOrdinal ] =
inConverterV != null ? inConverterV.convert( injectorRowMeta.getValueMeta( valueOrdinal ), value )
: value;
if ( debug ) {
setDebugStatus( reporter, "Injecting input record [" + row[ keyOrdinal ] + "] - [" + row[ valueOrdinal ] + "]" );
}
rowProducer.putRow( injectorRowMeta, row );
}
示例3: injectValue
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void injectValue( Object key, int keyOrdinal, ITypeConverter inConverterK,
Object value, int valueOrdinal, ITypeConverter inConverterV,
RowMetaInterface injectorRowMeta, RowProducer rowProducer, Reporter reporter )
throws Exception {
Object[] row = new Object[ injectorRowMeta.size() ];
row[ keyOrdinal ] =
inConverterK != null ? inConverterK.convert( injectorRowMeta.getValueMeta( keyOrdinal ), key ) : key;
row[ valueOrdinal ] =
inConverterV != null ? inConverterV.convert( injectorRowMeta.getValueMeta( valueOrdinal ), value ) : value;
if ( debug ) {
setDebugStatus( reporter, "Injecting input record [" + row[ keyOrdinal ] + "] - [" + row[ valueOrdinal ] + "]" );
}
rowProducer.putRow( injectorRowMeta, row );
}
示例4: subTransExecutionStatisticsIsCollected
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
@Test
public void subTransExecutionStatisticsIsCollected() throws Exception {
TransExecutorMeta executorMeta = getExecutorMeta( transExecutor );
executorMeta.setExecutionTimeField( "time" );
executorMeta.setExecutionResultTargetStepMeta( dummy );
Trans trans = createTrans( transMeta );
RowStepCollector endRc = listenExecutor( trans );
RowProducer rp = trans.addRowProducer( injector.getName(), 0 );
trans.startThreads();
RowMetaAndData testInput = new RowMetaAndData( createRowMetaForOneField(), SAMPLE_INPUT );
rp.putRow( testInput.getRowMeta(), testInput.getData() );
rp.finished();
trans.waitUntilFinished();
assertFalse( endRc.getRowsWritten().isEmpty() );
// execution time field
assertNotNull( endRc.getRowsWritten().get( 0 ).getData()[ 0 ] );
}
示例5: generateData
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
private void generateData( RowProducer rp ) {
RowMetaInterface rm = new RowMeta();
rm.addValueMeta( new ValueMetaInteger( "ID" ) );
rm.addValueMeta( new ValueMetaString( "personName" ) );
rm.addValueMeta( new ValueMetaString( "flag" ) );
for ( int i = 0; i < ROW_FOR_UPDATE; i++ ) {
rp.putRow( rm.clone(), new Object[] { "personNameUpdated" + i, i, UPDATE_FLAG } );
}
for ( int i = ROW_FOR_UPDATE; i < ROW_FOR_UPDATE + ROW_FOR_DELETE; i++ ) {
rp.putRow( rm.clone(), new Object[] { "personName" + i, i, DELETE_FLAG } );
}
for ( int i = ROW_FOR_UPDATE + ROW_FOR_DELETE; i < ROW_FOR_UPDATE + ROW_FOR_DELETE + ROW_FOR_INSERT; i++ ) {
rp.putRow( rm.clone(), new Object[] { "personNameInserted" + i, i, INSERT_FLAG } );
}
}
示例6: injectDataSetIntoStep
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
private void injectDataSetIntoStep( final Trans trans, final TransMeta transMeta,
final String dataSetName, final MetaStoreFactory<DataSet> dataSetFactory,
final Repository repository, final IMetaStore metaStore, final StepMeta stepMeta,
TransUnitTestSetLocation inputLocation ) throws MetaStoreException, KettleException {
final DataSet dataSet = dataSetFactory.loadElement( dataSetName );
final DataSetGroup group = dataSet.getGroup();
final Database database = new Database( trans, group.getDatabaseMeta() );
final LogChannelInterface log = trans.getLogChannel();
final RowMetaInterface injectRowMeta = DataSetConst.getStepOutputFields(log, transMeta, stepMeta, dataSet, inputLocation);
final RowProducer rowProducer = trans.addRowProducer( stepMeta.getName(), 0 );
// Look for the step into which we'll inject rows...
//
StepMetaDataCombi combi = null;
for ( StepMetaDataCombi step : trans.getSteps() ) {
if ( step.stepname.equals( stepMeta.getName() ) ) {
combi = step;
break;
}
}
if ( combi != null ) {
log.logBasic( "Injecting data set '" + dataSetName + "' into step '" + stepMeta.getName() + "', fields: "+injectRowMeta.toStringMeta() );
final List<Object[]> rows = dataSet.getAllRows(log, inputLocation, injectRowMeta);
// Pass rows
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
for( Object[] row : rows ) {
// pass the row with the external names
//
rowProducer.putRow( injectRowMeta, row );
}
rowProducer.finished();
} catch ( Exception e ) {
throw new RuntimeException( "Problem injecting data set '" + dataSetName + "' row into step '" + stepMeta.getName() + "'", e );
}
}
};
Thread thread = new Thread( runnable );
thread.start();
} finally {
database.disconnect();
}
}
}
示例7: test
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
/**
* Runs the transformation with the below input parameters
* @param inputData JSON string
* @param ignoreMissingPath boolean
* @param defaultPathLeafToNull boolean
* @return Transformation Results
*/
private List<RowMetaAndData> test(String inputData, boolean ignoreMissingPath, boolean defaultPathLeafToNull)
throws Exception {
KettleEnvironment.init();
// Create a new transformation
TransMeta transMeta = new TransMeta();
transMeta.setName("testFastJsonInput");
PluginRegistry registry = PluginRegistry.getInstance();
// Create Injector
String injectorStepName = "injector step";
StepMeta injectorStep = TestUtilities.createInjectorStep(injectorStepName, registry);
transMeta.addStep(injectorStep);
// Create a FastJsonInput step
String fastJsonInputName = "FastJsonInput step";
StepMeta fastJsonInputStep = createFastJsonInputStep(fastJsonInputName, registry, ignoreMissingPath,
defaultPathLeafToNull);
transMeta.addStep(fastJsonInputStep);
// TransHopMeta between injector step and FastJsonInput
TransHopMeta injector_hop_fjis = new TransHopMeta(injectorStep, fastJsonInputStep);
transMeta.addTransHop(injector_hop_fjis);
// Create a dummy step
String dummyStepName = "dummy step";
StepMeta dummyStep = TestUtilities.createDummyStep(dummyStepName, registry);
transMeta.addStep(dummyStep);
// TransHopMeta between FastJsonInput and Dummy
TransHopMeta fjis_hop_dummy = new TransHopMeta(fastJsonInputStep, dummyStep);
transMeta.addTransHop(fjis_hop_dummy);
// Execute the transformation
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
// Create a row collector and add it to the dummy step interface
StepInterface si = trans.getStepInterface(dummyStepName, 0);
RowStepCollector dummyRowCollector = new RowStepCollector();
si.addRowListener(dummyRowCollector);
// Create a row producer
RowProducer rowProducer = trans.addRowProducer(injectorStepName, 0);
trans.startThreads();
// create the rows
List<RowMetaAndData> inputList = createInputData(inputData);
for (RowMetaAndData rowMetaAndData : inputList) {
rowProducer.putRow(rowMetaAndData.getRowMeta(), rowMetaAndData.getData());
}
rowProducer.finished();
trans.waitUntilFinished();
return dummyRowCollector.getRowsWritten();
}
示例8: testInjector
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
/**
* Test case for injector step... also a show case on how
* to use injector.
*/
public void testInjector() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("injectortest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
TransHopMeta hi = new TransHopMeta(injectorStep, dummyStep);
transMeta.addTransHop(hi);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector rc = new RowStepCollector();
si.addRowListener(rc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = rc.getRowsWritten();
checkRows(resultRows, inputList);
}
示例9: testCaseSensitiveNoPreviousSort
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void testCaseSensitiveNoPreviousSort() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {false});
String uniqueRowsStepPid = steploader.getStepPluginID(urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}
示例10: testCaseInsensitiveNoPreviousSort
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
EnvUtil.environmentInit();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
StepLoader steploader = StepLoader.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = steploader.getStepPluginID(im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {true});
String uniqueRowsStepPid = steploader.getStepPluginID(urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = steploader.getStepPluginID(dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
示例11: testInjector
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
/**
* Test case for injector step... also a show case on how
* to use injector.
*/
public void testInjector() throws Exception
{
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("injectortest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
TransHopMeta hi = new TransHopMeta(injectorStep, dummyStep);
transMeta.addTransHop(hi);
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector rc = new RowStepCollector();
si.addRowListener(rc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for (RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = rc.getRowsWritten();
checkRows(resultRows, inputList);
}
示例12: createAndTestTrans
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
protected Trans createAndTestTrans( PluginRegistry registry, TransMeta transMeta, StepMeta injectorStep,
StepMeta csvInputStep, String fileName, int numRows ) throws KettleException {
TransHopMeta hi = new TransHopMeta( injectorStep, csvInputStep );
transMeta.addTransHop( hi );
//
// Create a dummy step 1
//
String dummyStepname1 = "dummy step 1";
DummyTransMeta dm1 = new DummyTransMeta();
String dummyPid1 = registry.getPluginId( StepPluginType.class, dm1 );
StepMeta dummyStep1 = new StepMeta( dummyPid1, dummyStepname1, dm1 );
transMeta.addStep( dummyStep1 );
TransHopMeta hi1 = new TransHopMeta( csvInputStep, dummyStep1 );
transMeta.addTransHop( hi1 );
// Now execute the transformation...
Trans trans = new Trans( transMeta );
trans.prepareExecution( null );
StepInterface si = trans.getStepInterface( dummyStepname1, 0 );
RowStepCollector dummyRc1 = new RowStepCollector();
si.addRowListener( dummyRc1 );
RowProducer rp = trans.addRowProducer( injectorStep.getName(), 0 );
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData( fileName );
Iterator<RowMetaAndData> it = inputList.iterator();
while ( it.hasNext() ) {
RowMetaAndData rm = it.next();
rp.putRow( rm.getRowMeta(), rm.getData() );
}
rp.finished();
trans.waitUntilFinished();
// Compare the results
List<RowMetaAndData> resultRows = dummyRc1.getRowsWritten();
List<RowMetaAndData> goldenImageRows = createResultData1();
checkRows( goldenImageRows, resultRows, numRows );
return trans;
}
示例13: testCaseInsensitiveNoPreviousSort
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void testCaseInsensitiveNoPreviousSort() throws Exception
{
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {true});
String uniqueRowsStepPid = registry.getPluginId(StepPluginType.class, urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseInsensitiveNoPreviousSort(), resultRows);
}
示例14: testInjector
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
/**
* Test case for injector step... also a show case on how to use injector.
*/
public void testInjector() throws Exception {
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName( "injectortest" );
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId( StepPluginType.class, im );
StepMeta injectorStep = new StepMeta( injectorPid, injectorStepname, im );
transMeta.addStep( injectorStep );
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId( StepPluginType.class, dm );
StepMeta dummyStep = new StepMeta( dummyPid, dummyStepname, dm );
transMeta.addStep( dummyStep );
TransHopMeta hi = new TransHopMeta( injectorStep, dummyStep );
transMeta.addTransHop( hi );
// Now execute the transformation...
Trans trans = new Trans( transMeta );
trans.prepareExecution( null );
StepInterface si = trans.getStepInterface( dummyStepname, 0 );
RowStepCollector rc = new RowStepCollector();
si.addRowListener( rc );
RowProducer rp = trans.addRowProducer( injectorStepname, 0 );
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList ) {
rp.putRow( rm.getRowMeta(), rm.getData() );
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = rc.getRowsWritten();
checkRows( resultRows, inputList );
}
示例15: testCaseSensitiveNoPreviousSort
import org.pentaho.di.trans.RowProducer; //导入方法依赖的package包/类
public void testCaseSensitiveNoPreviousSort() throws Exception
{
KettleEnvironment.init();
//
// Create a new transformation...
//
TransMeta transMeta = new TransMeta();
transMeta.setName("uniquerowstest");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector step...
//
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, (StepMetaInterface)im);
transMeta.addStep(injectorStep);
//
// Create a unique rows step
//
String uniqueRowsStepname = "unique rows step";
UniqueRowsMeta urm = new UniqueRowsMeta();
urm.setCompareFields(new String[] {"KEY"});
urm.setCaseInsensitive(new boolean[] {false});
String uniqueRowsStepPid = registry.getPluginId(StepPluginType.class, urm);
StepMeta uniqueRowsStep = new StepMeta(uniqueRowsStepPid, uniqueRowsStepname, (StepMetaInterface)urm);
transMeta.addStep(uniqueRowsStep);
transMeta.addTransHop(new TransHopMeta(injectorStep, uniqueRowsStep));
//
// Create a dummy step
//
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, (StepMetaInterface)dm);
transMeta.addStep(dummyStep);
transMeta.addTransHop(new TransHopMeta(uniqueRowsStep, dummyStep));
// Now execute the transformation...
Trans trans = new Trans(transMeta);
trans.prepareExecution(null);
StepInterface si = trans.getStepInterface(dummyStepname, 0);
RowStepCollector dummyRc = new RowStepCollector();
si.addRowListener(dummyRc);
RowProducer rp = trans.addRowProducer(injectorStepname, 0);
trans.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
for ( RowMetaAndData rm : inputList )
{
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
trans.waitUntilFinished();
List<RowMetaAndData> resultRows = dummyRc.getRowsWritten();
checkRows(createResultDataCaseSensitiveNoPreviousSort(), resultRows);
}