private Object[] constructErrorRow( RowMetaInterface rowMeta, Object[] r, String keyField, String referenceValue, String compareValue ) throws KettleException { if ( data.errorRowMeta == null ) { data.errorRowMeta = rowMeta.clone(); } r[data.keyDescIndex] = keyField; r[data.valueReferenceIndex] = referenceValue; r[data.valueCompareIndex] = compareValue; return r; }
@Override public RowMetaAndData clone() { RowMetaAndData c = new RowMetaAndData(); c.rowMeta = rowMeta.clone(); try { c.data = rowMeta.cloneRow( data ); } catch ( KettleValueException e ) { throw new RuntimeException( "Problem with clone row detected in RowMetaAndData", e ); } return c; }
/** * @return the cache value row metadata. The items that are cached is basically the return row metadata:<br> * - Technical key (Integer) - Version (Integer) - */ private RowMetaInterface assembleCacheValueRowMeta() { RowMetaInterface cacheRowMeta = data.returnRowMeta.clone(); // The technical key and version are always an Integer... // /* * cacheRowMeta.getValueMeta(0).setType(ValueMetaInterface.TYPE_INTEGER); * cacheRowMeta.getValueMeta(1).setType(ValueMetaInterface.TYPE_INTEGER); */ return cacheRowMeta; }
public void put( DBCacheEntry entry, RowMetaInterface fields ) { if ( !usecache ) { return; } RowMetaInterface copy = fields.clone(); cache.put( entry, copy ); // System.out.println("Cache store: "+copy.toStringMeta()); // System.out.println("Cache store entry="+entry.sql ); }
/** * Get the fields as a row generated by a database cache entry * * @param entry * the entry to look for * @return the fields as a row generated by a database cache entry */ public RowMetaInterface get( DBCacheEntry entry ) { if ( !usecache ) { return null; } RowMetaInterface fields = cache.get( entry ); if ( fields != null ) { fields = fields.clone(); // Copy it again! // System.out.println("Cache hit!!, fields="+fields.toStringMeta() ); // System.out.println("Cache hit entry="+entry.sql ); } return fields; }
private static RowMetaInterface[] cloneRowMetaInterfaces( RowMetaInterface[] inform ) { RowMetaInterface[] cloned = inform.clone(); for ( int i = 0; i < cloned.length; i++ ) { if ( cloned[i] != null ) { cloned[i] = cloned[i].clone(); } } return cloned; } }
/** * Initialize <code>this.data</code> * * @throws KettleStepException */ private void setupData() throws KettleStepException { data.nextBufferRowIdx = 0; data.inputRowMeta = getInputRowMeta().clone(); // only available after first getRow(); data.inputRowBuffer = new Object[batchSize][]; data.outputRowMeta = data.inputRowMeta.clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); }
private void putRowToRowSet( RowSet rs, RowMetaInterface rowMeta, Object[] row ) { RowMetaInterface toBeSent; RowMetaInterface metaFromRs = rs.getRowMeta(); if ( metaFromRs == null ) { // RowSet is not initialised so far toBeSent = rowMeta.clone(); } else { // use the existing toBeSent = metaFromRs; } while ( !rs.putRow( toBeSent, row ) ) { if ( isStopped() && !safeStopped.get() ) { return; } } }
public RowMetaInterface getAllFields( RowMetaInterface inputRowMeta ) { RowMetaInterface rowMeta = inputRowMeta.clone(); for ( CalculatorMetaFunction fn : getCalculation() ) { if ( !Utils.isEmpty( fn.getFieldName() ) ) { // It's a new field! ValueMetaInterface v = getValueMeta( fn, null ); rowMeta.addValueMeta( v ); } } return rowMeta; }
private void putToReadOnlyCache( Database db, List<Object[]> rows ) { ReadAllCache.Builder cacheBuilder = new ReadAllCache.Builder( data, rows.size() ); // all keys have the same row meta, // it is useless to re-create it each time RowMetaInterface returnRowMeta = db.getReturnRowMeta(); cacheBuilder.setKeysMeta( returnRowMeta.clone() ); final int keysAmount = meta.getStreamKeyField1().length; // Copy the data into 2 parts: key and value... // final int valuesAmount = data.returnMeta.size(); for ( Object[] row : rows ) { Object[] keyData = new Object[ keysAmount ]; System.arraycopy( row, 0, keyData, 0, keysAmount ); Object[] valueData = new Object[ valuesAmount ]; System.arraycopy( row, keysAmount, valueData, 0, valuesAmount ); cacheBuilder.add( keyData, valueData ); incrementLinesInput(); } data.cache = cacheBuilder.build(); }
public Object[] getRow() throws KettleException { Object[] row = parent.getRowImpl(); if ( updateRowMeta ) { // Update data.inputRowMeta and data.outputRowMeta RowMetaInterface inputRowMeta = parent.getInputRowMeta(); data.inputRowMeta = inputRowMeta; data.outputRowMeta = inputRowMeta == null ? null : getTransMeta().getThisStepFields( getStepMeta(), null, inputRowMeta.clone() ); updateRowMeta = false; } return row; }
private void prepareProcessPreviousFields() { if ( getInputRowMeta() == null ) { data.previousFieldsNumber = 0; data.finalOutputRowMeta = data.outputRowMeta; } else { data.previousFieldsNumber = getInputRowMeta().size(); data.finalOutputRowMeta = getInputRowMeta().clone(); meta.getFields( data.finalOutputRowMeta, getStepname(), null, null, this, repository, metaStore ); } }
public void run() { StepMeta stepMeta = transMeta.findStep( stepname ); if ( stepMeta != null ) { try { inputRowMeta = transMeta.getPrevStepFields( stepMeta ); infoRowMeta = transMeta.getPrevInfoFields( stepMeta ); outputRowMeta = transMeta.getThisStepFields( stepMeta, null, inputRowMeta.clone() ); populateFieldsTree(); } catch ( KettleException e ) { log.logError( BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), e ); } } } };
@Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { try { RowMetaInterface rowMeta = inputRowMeta.clone(); inputRowMeta.clear(); inputRowMeta.addRowMeta( rowMeta ); getSelectFields( inputRowMeta, name ); getDeleteFields( inputRowMeta ); getMetadataFields( inputRowMeta, name ); } catch ( Exception e ) { throw new KettleStepException( e ); } }
@Test public void testDummyTransWritesOutputWithInputRow() throws KettleException { DummyTrans dummy = new DummyTrans( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); dummy.init( stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface ); Object[] row = new Object[] { "abcd" }; RowSet rowSet = stepMockHelper.getMockInputRowSet( row ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( rowSet.getRowMeta() ).thenReturn( inputRowMeta ); dummy.addRowSetToInputRowSets( rowSet ); RowSet outputRowSet = mock( RowSet.class ); dummy.addRowSetToOutputRowSets( outputRowSet ); when( outputRowSet.putRow( inputRowMeta, row ) ).thenReturn( true ); dummy.processRow( stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface ); verify( outputRowSet, times( 1 ) ).putRow( inputRowMeta, row ); } }
/** * Attempts to put the <code>row</code> onto the underlying <code>rowProducer</code> during its timeout period. * Returns <code>true</code> if the operation completed successfully and <code>false</code> otherwise. * * @param rowMeta input row's meta data * @param row input row * @return <code>true</code> if the <code>row</code> was put successfully */ public boolean putRow( RowMetaInterface rowMeta, Object[] row ) { if ( first ) { first = false; renamedRowMeta = rowMeta.clone(); for ( MappingValueRename valueRename : inputDefinition.getValueRenames() ) { ValueMetaInterface valueMeta = renamedRowMeta.searchValueMeta( valueRename.getSourceValueName() ); if ( valueMeta != null ) { valueMeta.setName( valueRename.getTargetValueName() ); } } } return rowProducer.putRow( renamedRowMeta, row, false ); }
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository, IMetaStore metaStore ) throws KettleStepException { RowMetaInterface out = prev.clone(); getFields( out, stepMeta.getName(), new RowMetaInterface[] { info, }, null, transMeta, repository, metaStore ); if ( out != null ) { for ( int i = 0; i < out.size(); i++ ) { ValueMetaInterface outvalue = out.getValueMeta( i ); DatabaseImpact di = new DatabaseImpact( DatabaseImpact.TYPE_IMPACT_READ, transMeta.getName(), stepMeta.getName(), databaseMeta .getDatabaseName(), "", outvalue.getName(), outvalue.getName(), stepMeta.getName(), sql, BaseMessages.getString( PKG, "DynamicSQLRowMeta.DatabaseImpact.Title" ) ); impact.add( di ); } } }
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException { meta = (RowsToResultMeta) smi; data = (RowsToResultData) sdi; Object[] r = getRow(); // get row, set busy! if ( r == null ) { // no more input to be expected... getTrans().getResultRows().addAll( data.rows ); setOutputDone(); return false; } // Add all rows to rows buffer... data.rows.add( new RowMetaAndData( getInputRowMeta(), r ) ); data.outputRowMeta = getInputRowMeta().clone(); meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore ); putRow( data.outputRowMeta, r ); // copy row to possible alternate // rowset(s). if ( checkFeedback( getLinesRead() ) ) { logBasic( BaseMessages.getString( PKG, "RowsToResult.Log.LineNumber" ) + getLinesRead() ); } return true; }
public boolean runtimeInit() throws KettleStepException { data.setOutputRowMeta( getInputRowMeta().clone() ); meta.getFields( data.getOutputRowMeta(), getStepname(), null, null, this, repository, metaStore ); data.setRuleFilePath( meta.getRuleFile() ); data.setRuleString( meta.getRuleDefinition() ); data.initializeRules(); data.initializeColumns( getInputRowMeta() ); return true; }
public boolean runtimeInit() throws KettleStepException { try { data.setOutputRowMeta( getInputRowMeta().clone() ); meta.setKeepInputFields( false ); meta.getFields( data.getOutputRowMeta(), getStepname(), null, null, this, repository, metaStore ); data.setRuleFilePath( meta.getRuleFile() ); data.setRuleString( meta.getRuleDefinition() ); data.initializeRules(); data.initializeInput( getInputRowMeta() ); return true; } catch ( Exception e ) { throw new KettleStepException( e ); } }