當前位置: 首頁>>代碼示例>>Java>>正文


Java Trans.addRowProducer方法代碼示例

本文整理匯總了Java中org.pentaho.di.trans.Trans.addRowProducer方法的典型用法代碼示例。如果您正苦於以下問題:Java Trans.addRowProducer方法的具體用法?Java Trans.addRowProducer怎麽用?Java Trans.addRowProducer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.pentaho.di.trans.Trans的用法示例。


在下文中一共展示了Trans.addRowProducer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: injectDataSetIntoStep

import org.pentaho.di.trans.Trans; //導入方法依賴的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();
    }
  }
}
 
開發者ID:mattcasters,項目名稱:pentaho-pdi-dataset,代碼行數:56,代碼來源:InjectDataSetIntoTransExtensionPoint.java

示例2: test

import org.pentaho.di.trans.Trans; //導入方法依賴的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();
}
 
開發者ID:etdube,項目名稱:pdi-fastjsoninput-plugin,代碼行數:65,代碼來源:FastJsonInputTest.java

示例3: testInjector

import org.pentaho.di.trans.Trans; //導入方法依賴的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);
  }
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:67,代碼來源:InjectorTest.java

示例4: testCaseSensitiveNoPreviousSort

import org.pentaho.di.trans.Trans; //導入方法依賴的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);
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:75,代碼來源:UniqueRowsTest.java

示例5: testCaseInsensitiveNoPreviousSort

import org.pentaho.di.trans.Trans; //導入方法依賴的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);
}
 
開發者ID:icholy,項目名稱:geokettle-2.0,代碼行數:75,代碼來源:UniqueRowsTest.java


注:本文中的org.pentaho.di.trans.Trans.addRowProducer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。