Search in sources :

Example 16 with ContainerTable

use of org.knime.core.data.container.ContainerTable in project knime-core by knime.

the class LiftChartNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File dataFile1 = new File(nodeInternDir, DATA_FILE + "1");
    File dataFile2 = new File(nodeInternDir, DATA_FILE + "2");
    ContainerTable dataCont1 = DataContainer.readFromZip(dataFile1);
    ContainerTable dataCont2 = DataContainer.readFromZip(dataFile2);
    m_dataArray = new DataArray[2];
    m_dataArray[0] = new DefaultDataArray(dataCont1, 1, (int) dataCont1.size(), exec.createSubProgress(0.5));
    m_dataArray[1] = new DefaultDataArray(dataCont2, 1, (int) dataCont2.size(), exec.createSubProgress(0.5));
}
Also used : DefaultDataArray(org.knime.base.node.util.DefaultDataArray) File(java.io.File) ContainerTable(org.knime.core.data.container.ContainerTable)

Example 17 with ContainerTable

use of org.knime.core.data.container.ContainerTable in project knime-core by knime.

the class LinReg2LearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File inFile = new File(internDir, FILE_SAVE);
    ModelContentRO c = ModelContent.loadFromXML(new BufferedInputStream(new GZIPInputStream(new FileInputStream(inFile))));
    try {
        ModelContentRO specContent = c.getModelContent(CFG_SPEC);
        DataTableSpec spec = DataTableSpec.load(specContent);
        ModelContentRO parContent = c.getModelContent(CFG_LinReg2_CONTENT);
        m_content = LinearRegressionContent.load(parContent, spec);
    } catch (InvalidSettingsException ise) {
        IOException ioe = new IOException("Unable to restore state: " + ise.getMessage());
        ioe.initCause(ise);
        throw ioe;
    }
    File dataFile = new File(internDir, FILE_DATA);
    ContainerTable t = DataContainer.readFromZip(dataFile);
    int rowCount = t.getRowCount();
    m_rowContainer = new DefaultDataArray(t, 1, rowCount, exec);
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) DataTableSpec(org.knime.core.data.DataTableSpec) ModelContentRO(org.knime.core.node.ModelContentRO) BufferedInputStream(java.io.BufferedInputStream) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DefaultDataArray(org.knime.base.node.util.DefaultDataArray) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) ContainerTable(org.knime.core.data.container.ContainerTable)

Example 18 with ContainerTable

use of org.knime.core.data.container.ContainerTable in project knime-core by knime.

the class HierarchicalClusterNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    // distances
    File distFile = new File(nodeInternDir, CFG_DIST_DATA);
    ContainerTable table1 = DataContainer.readFromZip(distFile);
    m_fusionTable = new DefaultDataArray(table1, 1, table1.getRowCount());
    // data rows
    File dataFile = new File(nodeInternDir, CFG_H_CLUST_DATA);
    ContainerTable table2 = DataContainer.readFromZip(dataFile);
    m_dataArray = new DefaultDataArray(table2, 1, table2.getRowCount());
    File f = new File(nodeInternDir, CFG_HCLUST);
    FileInputStream fis = new FileInputStream(f);
    NodeSettingsRO settings = NodeSettings.loadFromXML(fis);
    // if we had some data...
    if (m_dataArray.size() > 0) {
        // we also have some clustering nodes
        try {
            m_rootNode = ClusterNode.loadFromXML(settings, m_dataArray);
        } catch (InvalidSettingsException e) {
            throw new IOException(e.getMessage());
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DefaultDataArray(org.knime.base.node.util.DefaultDataArray) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) IOException(java.io.IOException) File(java.io.File) ContainerTable(org.knime.core.data.container.ContainerTable) FileInputStream(java.io.FileInputStream)

Example 19 with ContainerTable

use of org.knime.core.data.container.ContainerTable in project knime-core by knime.

the class ReadTableNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            exec.setMessage("Extract temporary table");
            ContainerTable table = extractTable(exec.createSubExecutionContext(0.4));
            exec.setMessage("Streaming Output");
            RowOutput output = (RowOutput) outputs[0];
            execute(table, output, exec.createSubExecutionContext(0.6));
        }
    };
}
Also used : BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) ContainerTable(org.knime.core.data.container.ContainerTable)

Example 20 with ContainerTable

use of org.knime.core.data.container.ContainerTable in project knime-core by knime.

the class ReadTableNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    exec.setMessage("Extracting temporary table");
    ContainerTable table = extractTable(exec.createSubExecutionContext(0.4));
    exec.setMessage("Reading into final format");
    BufferedDataTableRowOutput c = new BufferedDataTableRowOutput(exec.createDataContainer(table.getDataTableSpec(), true));
    execute(table, c, exec.createSubExecutionContext(0.6));
    return new BufferedDataTable[] { c.getDataTable() };
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) ContainerTable(org.knime.core.data.container.ContainerTable) BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput)

Aggregations

ContainerTable (org.knime.core.data.container.ContainerTable)32 File (java.io.File)18 DefaultDataArray (org.knime.base.node.util.DefaultDataArray)13 FileInputStream (java.io.FileInputStream)12 IOException (java.io.IOException)11 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)9 BufferedInputStream (java.io.BufferedInputStream)7 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)7 DataTable (org.knime.core.data.DataTable)5 DataTableSpec (org.knime.core.data.DataTableSpec)5 Map (java.util.Map)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 ReferencedFile (org.knime.core.internal.ReferencedFile)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Test (org.junit.Test)3 RowKey (org.knime.core.data.RowKey)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3