org.knime.core.data.container
Class ContainerTable

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

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

Class implementing the DataTable interface and using a buffer from a DataContainer as data source. This class doesn't do functional things. It only provides the DataTable methods.

We split it from the Buffer implementation as a buffer is dynamic in size. This table should only be used when the buffer has been fixed.

Author:
Bernd Wiswedel, University of Konstanz

Constructor Summary
ContainerTable(Buffer buffer)
          Create new Table based on a Buffer.
ContainerTable(CopyOnAccessTask readTask, DataTableSpec spec)
          Constructor when table is read from file.
 
Method Summary
 void clear()
          Do not call this method! It's used internally to delete temp files.
 void ensureOpen()
          Do not use this method (only invoked by the framework).
(package private)  Buffer getBuffer()
          Get reference to buffer.
 int getBufferID()
          Delegates to buffer to get its ID.
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 BufferedDataTable[] getReferenceTables()
          Returns an empty array.
 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.
protected  void restoreIntoMemory()
          Instruct the underlying buffer to cache the rows into main memory to accelerate future iterations.
 void saveToFile(File f, NodeSettingsWO settings, ExecutionMonitor exec)
          Do not call this method! Internal use! 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

ContainerTable

ContainerTable(Buffer buffer)
Create new Table based on a Buffer. This constructor is called from DataContainer.getTable().

Parameters:
buffer - To read data from.
See Also:
DataContainer.getTable()

ContainerTable

ContainerTable(CopyOnAccessTask readTask,
               DataTableSpec spec)
Constructor when table is read from file.

Parameters:
readTask - Carries out the copy process when iterator is requested (just once).
spec - The spec of this table.
Method Detail

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

getRowCount

public int getRowCount()
Row count of the table.

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

getBuffer

Buffer getBuffer()
Get reference to buffer.

Returns:
The buffer backing this object.

getBufferID

public int getBufferID()
Delegates to buffer to get its ID.

Returns:
the buffer ID
See Also:
Buffer.getBufferID()

restoreIntoMemory

protected void restoreIntoMemory()
Instruct the underlying buffer to cache the rows into main memory to accelerate future iterations. This method does nothing if the buffer is reading from memory already.

See Also:
Buffer.restoreIntoMemory()

saveToFile

public void saveToFile(File f,
                       NodeSettingsWO settings,
                       ExecutionMonitor exec)
                throws IOException,
                       CanceledExecutionException
Do not call this method! Internal use! Save the table to a file.

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

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.

clear

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

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

ensureOpen

public void ensureOpen()
Do not use this method (only invoked by the framework). Implementation of BufferedDataTable.ensureOpen().

Specified by:
ensureOpen in interface BufferedDataTable.KnowsRowCountTable

getReferenceTables

public BufferedDataTable[] getReferenceTables()
Returns an empty array. This method is used internally. Reference to the underlying tables, if any. A reference table exists if this object is just a wrapper, such as a RearrangeColumnsTable or if this table concatenates a set of other tables.

Specified by:
getReferenceTables in interface BufferedDataTable.KnowsRowCountTable
Returns:
The reference table or null.


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.