Search in sources :

Example 1 with IRowSet

use of org.apache.hop.core.IRowSet in project hop by apache.

the class TransformClassBase method findTargetRowSet.

public IRowSet findTargetRowSet(String tag) throws HopException {
    if (tag == null) {
        return null;
    }
    String transformName = data.targetMap.get(tag);
    if (Utils.isEmpty(transformName)) {
        throw new HopException(BaseMessages.getString(PKG, "TransformClassBase.Exception.UnableToFindTargetTransformNameForTag", tag));
    }
    IRowSet rowSet = findOutputRowSet(transformName);
    if (rowSet == null) {
        throw new HopException(BaseMessages.getString(PKG, "TransformClassBase.Exception.UnableToFindTargetRowSetForTransform", transformName));
    }
    return rowSet;
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowSet(org.apache.hop.core.IRowSet)

Example 2 with IRowSet

use of org.apache.hop.core.IRowSet in project hop by apache.

the class TransformClassBase method findInfoRowSet.

public IRowSet findInfoRowSet(String tag) throws HopException {
    if (tag == null) {
        return null;
    }
    String transformName = data.infoMap.get(tag);
    if (Utils.isEmpty(transformName)) {
        throw new HopException(BaseMessages.getString(PKG, "TransformClassBase.Exception.UnableToFindInfoTransformNameForTag", tag));
    }
    IRowSet rowSet = findInputRowSet(transformName);
    if (rowSet == null) {
        throw new HopException(BaseMessages.getString(PKG, "TransformClassBase.Exception.UnableToFindInfoRowSetForTransform", transformName));
    }
    return rowSet;
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowSet(org.apache.hop.core.IRowSet)

Example 3 with IRowSet

use of org.apache.hop.core.IRowSet in project hop by apache.

the class SingleThreadedPipelineExecutor method initializeObject.

public void initializeObject(final Pipeline pipeline, boolean handleExceptionsExternally) {
    this.pipeline = pipeline;
    this.handleExceptionsExternally = handleExceptionsExternally;
    this.log = pipeline.getLogChannel();
    transforms = pipeline.getTransforms();
    sortTransforms();
    done = new boolean[transforms.size()];
    nrDone = 0;
    transformInfoStreams = new ArrayList<>();
    transformInfoRowSets = new ArrayList<>();
    for (TransformMetaDataCombi combi : transforms) {
        List<IStream> infoStreams = combi.transformMeta.getTransform().getTransformIOMeta().getInfoStreams();
        transformInfoStreams.add(infoStreams);
        List<IRowSet> infoRowSets = new ArrayList<>();
        for (IStream infoStream : infoStreams) {
            IRowSet infoRowSet = pipeline.findRowSet(infoStream.getTransformName(), 0, combi.transformName, 0);
            if (infoRowSet != null) {
                infoRowSets.add(infoRowSet);
            }
        }
        transformInfoRowSets.add(infoRowSets);
    }
}
Also used : IRowSet(org.apache.hop.core.IRowSet) IStream(org.apache.hop.pipeline.transform.stream.IStream) ArrayList(java.util.ArrayList)

Example 4 with IRowSet

use of org.apache.hop.core.IRowSet in project hop by apache.

the class SingleThreadedPipelineExecutor method oneIteration.

/**
 * Give all transforms in the pipeline the chance to process all rows on input...
 *
 * @return true if more iterations can be performed. False if this is not the case.
 */
public boolean oneIteration() throws HopException {
    this.exceptionsRaisedCounter = 0;
    try {
        for (int s = 0; s < transforms.size() && !pipeline.isStopped(); s++) {
            if (!done[s]) {
                TransformMetaDataCombi combi = transforms.get(s);
                this.inProcessCombi = combi;
                // If this transform is waiting for data (text, db, and so on), we simply read all the
                // data
                // This means that it is impractical to use this pipeline type to load large files.
                // 
                boolean transformDone = false;
                // For every input row we call the processRow() method of the transform.
                // 
                List<IRowSet> infoRowSets = transformInfoRowSets.get(s);
                // 
                for (IRowSet rowSet : infoRowSets) {
                    boolean once = true;
                    while (once || (rowSet.size() > 0 && !transformDone)) {
                        once = false;
                        transformDone = !combi.transform.processRow();
                        if (combi.transform.getErrors() > 0) {
                            return false;
                        }
                    }
                }
                // Do normal processing of input rows...
                // 
                List<IRowSet> rowSets = combi.transform.getInputRowSets();
                // 
                if (rowSets.size() == 0) {
                    while (!transformDone && !pipeline.isStopped()) {
                        transformDone = !combi.transform.processRow();
                        if (combi.transform.getErrors() > 0) {
                            return false;
                        }
                    }
                } else {
                    // Since we can't be sure that the transform actually reads from the row sets where we
                    // measure rows,
                    // we simply count the total nr of rows on input. The transforms will find the rows in
                    // either row set.
                    // 
                    int nrRows = 0;
                    for (IRowSet rowSet : rowSets) {
                        nrRows += rowSet.size();
                    }
                    // 
                    for (int i = 0; i < nrRows; i++) {
                        transformDone = !combi.transform.processRow();
                        if (combi.transform.getErrors() > 0) {
                            return false;
                        }
                    }
                }
                // Signal the transform that a batch of rows has passed for this iteration (sort rows and
                // all)
                // 
                combi.transform.batchComplete();
                if (transformDone) {
                    nrDone++;
                }
                done[s] = transformDone;
            }
        }
    } catch (Exception e) {
        if (handleExceptionsExternally) {
            log.logDebug("An exception was raised during a transform's execution: " + inProcessCombi.transformName);
            this.exceptionsRaisedCounter += 1;
        } else
            throw new HopException("Error performing an iteration in a single threaded pipeline", e);
    }
    return nrDone < transforms.size() && !pipeline.isStopped();
}
Also used : HopException(org.apache.hop.core.exception.HopException) IRowSet(org.apache.hop.core.IRowSet) HopException(org.apache.hop.core.exception.HopException)

Example 5 with IRowSet

use of org.apache.hop.core.IRowSet in project hop by apache.

the class JoinRows method batchComplete.

@Override
public void batchComplete() throws HopException {
    IRowSet rowSet = getFirstInputRowSet();
    int repeats = 0;
    for (int i = 0; i < data.cache.length; i++) {
        if (repeats == 0) {
            repeats = 1;
        }
        if (data.cache[i] != null) {
            repeats *= data.cache[i].size();
        }
    }
    while (rowSet.size() > 0 && !isStopped()) {
        init();
    }
    // 
    for (int i = 0; i < repeats; i++) {
        init();
    }
}
Also used : IRowSet(org.apache.hop.core.IRowSet)

Aggregations

IRowSet (org.apache.hop.core.IRowSet)62 IRowMeta (org.apache.hop.core.row.IRowMeta)34 RowMeta (org.apache.hop.core.row.RowMeta)22 ILoggingObject (org.apache.hop.core.logging.ILoggingObject)17 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)15 HopException (org.apache.hop.core.exception.HopException)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 QueueRowSet (org.apache.hop.core.QueueRowSet)11 HopTransformException (org.apache.hop.core.exception.HopTransformException)10 IValueMeta (org.apache.hop.core.row.IValueMeta)6 IStream (org.apache.hop.pipeline.transform.stream.IStream)6 RowAdapter (org.apache.hop.pipeline.transform.RowAdapter)5 File (java.io.File)4 FileObject (org.apache.commons.vfs2.FileObject)4 SingleRowRowSet (org.apache.hop.core.SingleRowRowSet)4 HopFileException (org.apache.hop.core.exception.HopFileException)4 ITransformIOMeta (org.apache.hop.pipeline.transform.ITransformIOMeta)4 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)4 ParseException (java.text.ParseException)3