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);
}
}
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();
}
}
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);
}
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() };
}
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();
}
Aggregations