org.knime.core.data.container
Class RearrangeColumnsTable

java.lang.Object
  extended by org.knime.core.data.container.RearrangeColumnsTable
All Implemented Interfaces:
Iterable<DataRow>, DataTable, BufferedDataTable.KnowsRowCountTable

public final class RearrangeColumnsTable
extends Object
implements DataTable, BufferedDataTable.KnowsRowCountTable

Table implementation that is created based on a ColumnRearranger. This class is not intended for subclassing or to be used directly in any node implementation. Instead use the functionality provided through the ColumnRearranger and the ExecutionContext that is provided in the NodeModel's execute method. See ColumnRearranger for more details on how to use them.

Author:
Bernd Wiswedel, University of Konstanz

Constructor Summary
RearrangeColumnsTable(ReferencedFile f, NodeSettingsRO settings, Map<Integer,BufferedDataTable> tblRep, DataTableSpec spec, int tableID, HashMap<Integer,ContainerTable> bufferRep)
          Creates new object based on the content in settings and the content from the file f.
 
Method Summary
 void clear()
          Do not call this method! It's used internally to delete temp files.
static RearrangeColumnsTable create(ColumnRearranger rearranger, BufferedDataTable table, ExecutionMonitor subProgress, ExecutionContext context)
          This factory method is intended to be used immediately before the BufferedDataTable is created.
 void ensureOpen()
          Internal use.
 ContainerTable getAppendTable()
          Get reference to the appended table.
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 BufferedDataTable[] getReferenceTables()
          Get handle to the reference table in an array of length 1.
 int getRowCount()
          Row count of the table.
 CloseableRowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
 void putIntoTableRepository(HashMap<Integer,ContainerTable> rep)
          Put this table into the global table repository.
 void removeFromTableRepository(HashMap<Integer,ContainerTable> rep)
          Remove this table from global table repository.
 void saveToFile(File f, NodeSettingsWO s, ExecutionMonitor exec)
          Save the table to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RearrangeColumnsTable

public RearrangeColumnsTable(ReferencedFile f,
                             NodeSettingsRO settings,
                             Map<Integer,BufferedDataTable> tblRep,
                             DataTableSpec spec,
                             int tableID,
                             HashMap<Integer,ContainerTable> bufferRep)
                      throws IOException,
                             InvalidSettingsException
Creates new object based on the content in settings and the content from the file f. Used when the data is restored from disc.

Note: You should not be required to use this constructor!

Parameters:
f - The file to read from the newly appended columns.
settings - The settings containing the information how to assemble the table.
tblRep - The table repository (only available during start)
spec - The data table spec of the resulting table. This argument is null when the data to restore is written using KNIME 1.1.x or before.
tableID - buffer ID of underlying buffer.
bufferRep - Repository of buffers for blob (de)serialization.
Throws:
IOException - If reading the fails.
InvalidSettingsException - If the settings are invalid.
Method Detail

getReferenceTables

public BufferedDataTable[] getReferenceTables()
Get handle to the reference table in an array of length 1.

Specified by:
getReferenceTables in interface BufferedDataTable.KnowsRowCountTable
Returns:
The table providing likely most of the columns and the rowkeys.

getAppendTable

public ContainerTable getAppendTable()
Get reference to the appended table. This table must not be used publicly as the append table is corrupted: It does not contain proper row keys (it contains only the appended columns). This method returns null if this table only filters out some of the columns.

Returns:
Reference to append table.

getDataTableSpec

public DataTableSpec getDataTableSpec()
Returns the DataTableSpec object of this table which gives information about the structure of this data table.

Specified by:
getDataTableSpec in interface DataTable
Returns:
the DataTableSpec of this table

iterator

public CloseableRowIterator iterator()
Returns a row iterator which returns each row one-by-one from the table.

Specified by:
iterator in interface Iterable<DataRow>
Specified by:
iterator in interface DataTable
Specified by:
iterator in interface BufferedDataTable.KnowsRowCountTable
Returns:
row iterator
See Also:
DataRow

create

public static RearrangeColumnsTable create(ColumnRearranger rearranger,
                                           BufferedDataTable table,
                                           ExecutionMonitor subProgress,
                                           ExecutionContext context)
                                    throws CanceledExecutionException
This factory method is intended to be used immediately before the BufferedDataTable is created.

Parameters:
rearranger - The meta information how to assemble everything.
table - The reference table.
subProgress - The progress monitor for progress/cancel.
context - Used for data container creation.
Returns:
The newly created table.
Throws:
CanceledExecutionException - If canceled.
IllegalArgumentException - If the spec is not equal to the spec of the rearranger.

getRowCount

public int getRowCount()
Row count of the table.

Specified by:
getRowCount in interface BufferedDataTable.KnowsRowCountTable
Returns:
The row count.

saveToFile

public void saveToFile(File f,
                       NodeSettingsWO s,
                       ExecutionMonitor exec)
                throws IOException,
                       CanceledExecutionException
Save the table to a file.

Specified by:
saveToFile in interface BufferedDataTable.KnowsRowCountTable
Parameters:
f - To write to.
s - To add meta information to.
exec - For progress/cancel.
Throws:
IOException - If writing fails.
CanceledExecutionException - If canceled.

clear

public void clear()
Do not call this method! It's used internally to delete temp files. Any iteration on the table will fail!

Specified by:
clear in interface BufferedDataTable.KnowsRowCountTable
See Also:
BufferedDataTable.KnowsRowCountTable.clear()

ensureOpen

public void ensureOpen()
Internal use. Implementation of BufferedDataTable.ensureOpen().

Specified by:
ensureOpen in interface BufferedDataTable.KnowsRowCountTable

putIntoTableRepository

public void putIntoTableRepository(HashMap<Integer,ContainerTable> rep)
Put this table into the global table repository. Called when execution finished.

Specified by:
putIntoTableRepository in interface BufferedDataTable.KnowsRowCountTable
Parameters:
rep - The workflow table repository.

removeFromTableRepository

public void removeFromTableRepository(HashMap<Integer,ContainerTable> rep)
Remove this table from global table repository. Called when node is reset.

Specified by:
removeFromTableRepository in interface BufferedDataTable.KnowsRowCountTable
Parameters:
rep - The workflow table repository.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.