/** * Add a single value to a row of data * * @param rowData * The original row of data * @param the * length of the row data or of it's longer, the location of the new extra value in the returned data row * @param extra * The extra value to add * @return a new Array containing all elements, including the extra one */ public static Object[] addValueData( Object[] rowData, int length, Object extra ) { Object[] result = resizeArray( rowData, length + 1 ); result[length] = extra; return result; }
/** * Add two arrays and make one new one. * * @param one * The first array * @param the * length of the row data or of it's longer, the location of the new extra value in the returned data row * @param two * The second array * @return a new Array containing all elements from one and two after one another */ public static Object[] addRowData( Object[] one, int sourceLength, Object[] two ) { Object[] result = resizeArray( one, sourceLength + two.length ); System.arraycopy( two, 0, result, sourceLength, two.length ); return result; }
Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { // reserve room for the target field outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { // reserve room for the target field and re-map the fields outputRowData = new Object[ data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE ]; if ( r != null ) { // re-map the fields for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { // BTW: the new target field is not // here outputRowData[ i ] = r[ data.remainingFieldsInputOutputMapping[ i ] ]; } } } return outputRowData; }
synchronized Object[] getOneRow( RowMetaInterface rowMeta, Object[] row ) throws KettleException { Object[] rowData = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int index = 0; Set<Integer> numFieldsAlreadyBeenTransformed = new HashSet<Integer>(); for ( int i = 0; i < data.numFields; i++ ) { RowMetaInterface currentRowMeta = ( numFieldsAlreadyBeenTransformed.contains( data.inStreamNrs[i] ) ) ? data.outputRowMeta : getInputRowMeta(); String value = replaceString( currentRowMeta.getString( rowData, data.inStreamNrs[i] ), data.patterns[i], getResolvedReplaceByString( i, row ) ); if ( Utils.isEmpty( data.outStreamNrs[i] ) ) { // update field value rowData[data.inStreamNrs[i]] = value; numFieldsAlreadyBeenTransformed.add( data.inStreamNrs[i] ); } else { // add new field value rowData[data.inputFieldsNr + index++] = value; } } return rowData; }
private void addIdToRow( String id, int rowIndex ) { data.inputRowBuffer[rowIndex] = RowDataUtil.resizeArray( data.inputRowBuffer[rowIndex], getInputRowMeta().size() + 1 ); data.inputRowBuffer[rowIndex][getInputRowMeta().size()] = id; }
public Object[] addSequence( RowMetaInterface inputRowMeta, Object[] inputRowData ) throws KettleException { Object next = null; // Are we still in the sequence range? // if ( data.value >= ( data.startValue + data.increment ) ) { // Get a new value from the service... // data.startValue = data.slaveServer.getNextSlaveSequenceValue( data.sequenceName, data.increment ); data.value = data.startValue; } next = Long.valueOf( data.value ); data.value++; if ( next != null ) { Object[] outputRowData = inputRowData; if ( inputRowData.length < inputRowMeta.size() + 1 ) { outputRowData = RowDataUtil.resizeArray( inputRowData, inputRowMeta.size() + 1 ); } outputRowData[inputRowMeta.size()] = next; return outputRowData; } else { throw new KettleStepException( BaseMessages.getString( PKG, "GetSequence.Exception.CouldNotFindNextValueForSequence" ) + meta.getValuename() ); } }
private Object[] getOneRow() throws KettleException { if ( !openNextFile() ) { return null; } // Build an empty row based on the meta-data Object[] r; try { // Create new row or clone if ( meta.isFileField() ) { r = data.readrow.clone(); r = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { r = RowDataUtil.allocateRowData( data.outputRowMeta.size() ); } if ( meta.isSmartCount() && data.foundData ) { // We have data right the last separator, // we need to update the row count data.rownr++; } r[data.totalpreviousfields] = data.rownr; if ( meta.includeCountFiles() ) { r[data.totalpreviousfields + 1] = data.filenr; } incrementLinesInput(); } catch ( Exception e ) { throw new KettleException( "Unable to read row from file", e ); } return r; }
outputRowData = RowDataUtil.addRowData( data.readrow, data.totalPreviousFields, outputRowData ); } else { outputRowData = RowDataUtil.resizeArray( outputRowData, data.totalOutStreamFields );
parser.edifact(); r = RowDataUtil.resizeArray( r, data.outputRowMeta.size() );
Object[] newRow = RowDataUtil.resizeArray( rowData, data.outputRowMeta.size() ); int newIndex = rowMeta.size(); RowMetaInterface addMeta = data.db.getReturnRowMeta(); counter++; Object[] newRow = RowDataUtil.resizeArray( rowData, data.outputRowMeta.size() ); int newIndex = rowMeta.size(); for ( int i = 0; i < addMeta.size(); i++ ) { data.notfound = new Object[data.db.getReturnRowMeta().size()]; Object[] newRow = RowDataUtil.resizeArray( rowData, data.outputRowMeta.size() ); int newIndex = rowMeta.size(); for ( int i = 0; i < data.notfound.length; i++ ) {
Object[] outputRow = RowDataUtil.resizeArray( row, data.outputRowMeta.size() );
Object[] newRow = RowDataUtil.resizeArray( data.outputBuffer[j], data.outputRowMeta.size() );
Object[] newRow = RowDataUtil.resizeArray( data.outputBuffer[j], data.outputRowMeta.size() );
Object[] outputRowData = inputRowData; if ( inputRowData.length < inputRowMeta.size() + 1 ) { outputRowData = RowDataUtil.resizeArray( inputRowData, inputRowMeta.size() + 1 );
Object[] newRow = RowDataUtil.resizeArray( data.outputBuffer[j], data.outputRowMeta.size() );
Object[] outputRowData = RowDataUtil.resizeArray( rowData, data.outputMeta.size() ); int outputIndex = rowMeta.size();
Object[] outputRow = RowDataUtil.resizeArray( row, data.outputRowMeta.size() ); int outputIndex = getInputRowMeta().size();
counter++; Object[] newRow = RowDataUtil.resizeArray( rowData, data.outputRowMeta.size() ); int newIndex = rowMeta.size(); for ( int i = 0; i < addMeta.size(); i++ ) { Object[] newRow = RowDataUtil.resizeArray( rowData, data.outputRowMeta.size() ); int newIndex = rowMeta.size(); for ( int i = 0; i < data.notfound.length; i++ ) {
r = RowDataUtil.resizeArray( r, data.outputMeta.size() );
Object[] outputRow = RowDataUtil.resizeArray( row, data.outputRowMeta.size() );