Search in sources :

Example 1 with One2ManyCellFactory

use of org.knime.base.node.preproc.columntrans2.One2ManyCellFactory in project knime-core by knime.

the class One2ManyCol2PMMLNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    BufferedDataTable inData = (BufferedDataTable) inObjects[0];
    DataTableSpec dts = inData.getDataTableSpec();
    checkColumnsSpecs(dts);
    String[] includes = m_includedColumns.applyTo(dts).getIncludes();
    One2ManyCellFactory cellFactory = new One2ManyCellFactory(dts, Arrays.asList(includes), m_appendOrgColName);
    BufferedDataTable outData = exec.createColumnRearrangeTable(inData, createRearranger(dts, cellFactory), exec);
    if (m_pmmlOutEnabled) {
        // the optional PMML in port (can be null)
        PMMLPortObject inPMMLPort = m_pmmlInEnabled ? (PMMLPortObject) inObjects[1] : null;
        PMMLOne2ManyTranslator trans = new PMMLOne2ManyTranslator(cellFactory.getColumnMapping(), new DerivedFieldMapper(inPMMLPort));
        PMMLPortObjectSpecCreator creator = new PMMLPortObjectSpecCreator(inPMMLPort, outData.getDataTableSpec());
        PMMLPortObject outPMMLPort = new PMMLPortObject(creator.createSpec(), inPMMLPort);
        outPMMLPort.addGlobalTransformations(trans.exportToTransDict());
        return new PortObject[] { outData, outPMMLPort };
    } else {
        return new PortObject[] { outData };
    }
}
Also used : DerivedFieldMapper(org.knime.core.node.port.pmml.preproc.DerivedFieldMapper) DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) BufferedDataTable(org.knime.core.node.BufferedDataTable) One2ManyCellFactory(org.knime.base.node.preproc.columntrans2.One2ManyCellFactory) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Example 2 with One2ManyCellFactory

use of org.knime.base.node.preproc.columntrans2.One2ManyCellFactory in project knime-core by knime.

the class One2ManyCol2PMMLNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec inDataSpec = (DataTableSpec) inSpecs[0];
    m_appendOrgColName = false;
    String[] includes = m_includedColumns.applyTo(inDataSpec).getIncludes();
    if (includes.length <= 0) {
        setWarningMessage("No columns to transfrom selected. Will have no effect!");
    }
    // check if the values are present in the current spec
    if (includes.length > 0) {
        checkColumnsSpecs(inDataSpec);
    }
    CellFactory cellFactory = new One2ManyCellFactory(inDataSpec, Arrays.asList(includes), m_appendOrgColName);
    ColumnRearranger rearranger = createRearranger(inDataSpec, cellFactory);
    if (m_pmmlOutEnabled) {
        PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
        PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inDataSpec);
        return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
    } else {
        return new PortObjectSpec[] { rearranger.createSpec() };
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) One2ManyCellFactory(org.knime.base.node.preproc.columntrans2.One2ManyCellFactory) One2ManyCellFactory(org.knime.base.node.preproc.columntrans2.One2ManyCellFactory) CellFactory(org.knime.core.data.container.CellFactory) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Aggregations

One2ManyCellFactory (org.knime.base.node.preproc.columntrans2.One2ManyCellFactory)2 DataTableSpec (org.knime.core.data.DataTableSpec)2 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)2 CellFactory (org.knime.core.data.container.CellFactory)1 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)1 BufferedDataTable (org.knime.core.node.BufferedDataTable)1 PortObject (org.knime.core.node.port.PortObject)1 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)1 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)1 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)1 DerivedFieldMapper (org.knime.core.node.port.pmml.preproc.DerivedFieldMapper)1