Search in sources :

Example 46 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class TableSorterWorker method doInBackground.

/**
 * {@inheritDoc}
 */
@Override
protected DataTable doInBackground() throws Exception {
    // passed to table sorter for progress
    long rowCount;
    if (m_inputTable instanceof BufferedDataTable) {
        rowCount = ((BufferedDataTable) m_inputTable).size();
    } else if (m_inputTable instanceof ContainerTable) {
        rowCount = ((ContainerTable) m_inputTable).size();
    } else {
        // unknown, no progress
        rowCount = -1;
    }
    publish(new NodeProgress(0.0, "Starting table sort..."));
    Collection<String> sortColNames = new ArrayList<String>(2);
    DataTableSpec spec = m_inputTable.getDataTableSpec();
    for (int i : m_sortOrder.getSortColumnIndices()) {
        String name;
        if (i < 0) {
            // row id
            name = DataTableSorter.ROWKEY_SORT_SPEC.getName();
        } else {
            name = spec.getColumnSpec(i).getName();
        }
        sortColNames.add(name);
    }
    long start = System.currentTimeMillis();
    LOGGER.debug("Starting interactive table sorting on column(s) " + sortColNames);
    boolean[] sortOrders = m_sortOrder.getSortColumnOrder();
    // it DOES NOT respect blobs -- they will be copied (expensive)
    DataTableSorter sorter = new DataTableSorter(m_inputTable, rowCount, sortColNames, sortOrders, false);
    NodeProgressListener progLis = new NodeProgressListener() {

        @Override
        public void progressChanged(final NodeProgressEvent pe) {
            publish(pe.getNodeProgress());
        }
    };
    m_nodeProgressMonitor = new DefaultNodeProgressMonitor();
    ExecutionMonitor exec = new ExecutionMonitor(m_nodeProgressMonitor);
    m_nodeProgressMonitor.addProgressListener(progLis);
    try {
        DataTable result = sorter.sort(exec);
        long elapsedMS = System.currentTimeMillis() - start;
        String time = StringFormat.formatElapsedTime(elapsedMS);
        LOGGER.debug("Interactive table sorting finished (" + time + ")");
        return result;
    } finally {
        m_nodeProgressMonitor.removeProgressListener(progLis);
    }
}
Also used : DataTable(org.knime.core.data.DataTable) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableSpec(org.knime.core.data.DataTableSpec) NodeProgressListener(org.knime.core.node.workflow.NodeProgressListener) NodeProgress(org.knime.core.node.workflow.NodeProgress) ArrayList(java.util.ArrayList) ContainerTable(org.knime.core.data.container.ContainerTable) NodeProgressEvent(org.knime.core.node.workflow.NodeProgressEvent) DataTableSorter(org.knime.core.data.sort.DataTableSorter) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) BufferedDataTable(org.knime.core.node.BufferedDataTable) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 47 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class DataColumnPropertiesView method dispose.

/**
 * {@inheritDoc}
 * @since 3.6
 */
@Override
public void dispose() {
    TableContentModel contentModel = m_propsView.getContentModel();
    DataTable dataTable = contentModel.getDataTable();
    contentModel.setDataTable(null);
    if (dataTable instanceof ContainerTable) {
        ((ContainerTable) dataTable).clear();
    }
}
Also used : DataTable(org.knime.core.data.DataTable) TableContentModel(org.knime.core.node.tableview.TableContentModel) ContainerTable(org.knime.core.data.container.ContainerTable)

Example 48 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class InteractiveHiLiteCollectorNodeView method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
protected void modelChanged() {
    DataTable data = super.getNodeModel().getHiLiteAnnotationsTable();
    m_table.setDataTable(data);
    HiLiteHandler hdl = super.getNodeModel().getInHiLiteHandler(0);
    m_table.setHiLiteHandler(hdl);
    m_table.setColumnWidth(50);
}
Also used : DataTable(org.knime.core.data.DataTable) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler)

Example 49 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class RowFilterNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    DataTable in = inData[0];
    // in case the node was configured and the workflow is closed
    // (and saved), the row filter isn't configured upon reloading.
    // here, we give it a chance to configure itself (e.g. find the column
    // index)
    m_rowFilter.configure(in.getDataTableSpec());
    BufferedDataContainer container = exec.createDataContainer(in.getDataTableSpec());
    exec.setMessage("Searching first matching row...");
    try {
        int count = 0;
        RowFilterIterator it = new RowFilterIterator(in, m_rowFilter, exec);
        while (it.hasNext()) {
            DataRow row = it.next();
            count++;
            container.addRowToTable(row);
            exec.setMessage("Added row " + count + " (\"" + row.getKey() + "\")");
        }
    } catch (RowFilterIterator.RuntimeCanceledExecutionException rce) {
        throw rce.getCause();
    } finally {
        container.close();
    }
    return new BufferedDataTable[] { container.getTable() };
}
Also used : DataTable(org.knime.core.data.DataTable) BufferedDataTable(org.knime.core.node.BufferedDataTable) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataRow(org.knime.core.data.DataRow)

Example 50 with DataTable

use of org.knime.core.data.DataTable in project knime-core by knime.

the class TreeEnsembleLearnerNodeView method newModel.

private void newModel(final int index) {
    assert SwingUtilities.isEventDispatchThread();
    final MODEL nodeModel = getNodeModel();
    TreeEnsembleModel model = nodeModel.getEnsembleModel();
    DataTable hiliteRowSample = nodeModel.getHiliteRowSample();
    UpdateTreeWorker updateWorker = new UpdateTreeWorker(hiliteRowSample, model, index);
    UpdateTreeWorker old = m_updateWorkerRef.getAndSet(updateWorker);
    if (old != null) {
        old.cancel(true);
    }
    updateWorker.execute();
}
Also used : DataTable(org.knime.core.data.DataTable) TreeEnsembleModel(org.knime.base.node.mine.treeensemble.model.TreeEnsembleModel)

Aggregations

DataTable (org.knime.core.data.DataTable)64 BufferedDataTable (org.knime.core.node.BufferedDataTable)33 DataRow (org.knime.core.data.DataRow)20 DataTableSpec (org.knime.core.data.DataTableSpec)19 RowKey (org.knime.core.data.RowKey)14 DataCell (org.knime.core.data.DataCell)12 DataColumnSpec (org.knime.core.data.DataColumnSpec)12 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)11 DefaultTable (org.knime.core.data.def.DefaultTable)10 DefaultRow (org.knime.core.data.def.DefaultRow)8 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)7 DefaultDataArray (org.knime.base.node.util.DefaultDataArray)6 DataType (org.knime.core.data.DataType)6 PortObject (org.knime.core.node.port.PortObject)6 RowIterator (org.knime.core.data.RowIterator)5 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)5 ContainerTable (org.knime.core.data.container.ContainerTable)5 DataContainer (org.knime.core.data.container.DataContainer)5 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)5 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)5