org.knime.base.data.join
Class JoinedTable

java.lang.Object
  extended by org.knime.base.data.join.JoinedTable
All Implemented Interfaces:
Iterable<DataRow>, DataTable

public class JoinedTable
extends Object
implements DataTable

Creates new table by appending all columns from right table to the left table. This, of course, only if both table agree on the row keys.

What is worth to notice about the order: Ideally, the order in both tables is the same. If that is not the case, the order of the left table is the one that counts, followed by the ones that are in the right table but not in the left one.

If any table contains row keys that the other does not, the columns provided by the respectively other table are filled with missing cells. If the column type is one of DoubleCell, IntCell or StringCell, the singleton instances of missing cells (No, it is not missing, but declared as having a missing value). Otherwise, this implementation will throw an exception during the iteration, saying that it cannot instantiate a missing cell. (If it could do so, it would still violate the column type given in table spec.)

Author:
Bernd Wiswedel, University of Konstanz

Field Summary
static String METHOD_APPEND_SUFFIX
          Method on how to treat duplicate column names: append suffix.
static String METHOD_FAIL
          Method on how to treat duplicate column names: fail execution.
static String METHOD_FILTER
          Method on how to treat duplicate column names: filter.
 
Constructor Summary
JoinedTable(DataTable left, DataTable right)
          Creates new table with the left part defined by left and the appended right part given by right.
JoinedTable(DataTable left, DataTable right, String duplicateMethod, String suffix, boolean inMemory)
          Creates a new table with the left part defined by left and the appended right part given by right.
 
Method Summary
static DataCell[] createMissingCells(DataTableSpec spec)
          Fills an array with missing values according to the spec.
static DataTableSpec createSpec(DataTableSpec left, DataTableSpec right)
          Creates a new DataTableSpec as an result of merging a left and a right table.
static DataTableSpec createSpec(DataTableSpec left, DataTableSpec right, String duplicateMethod, String suffix)
          Creates a new DataTableSpec as an result of merging a left and a right table.
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
protected  DataTable getLeftTable()
          Get reference to underlying left table.
protected  DataTable getRightTable()
          Get reference to underlying right table.
(package private)  boolean isPrintedErrorOnMissing()
          Requested by iterated.
(package private)  boolean isPrintedErrorOnSorting()
          Requested by iterated.
 RowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
(package private)  void setPrintedErrorOnMissing(boolean printedErrorOnMissing)
           
(package private)  void setPrintedErrorOnSorting(boolean printedErrorOnSorting)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHOD_FAIL

public static final String METHOD_FAIL
Method on how to treat duplicate column names: fail execution.

See Also:
Constant Field Values

METHOD_FILTER

public static final String METHOD_FILTER
Method on how to treat duplicate column names: filter.

See Also:
Constant Field Values

METHOD_APPEND_SUFFIX

public static final String METHOD_APPEND_SUFFIX
Method on how to treat duplicate column names: append suffix.

See Also:
Constant Field Values
Constructor Detail

JoinedTable

public JoinedTable(DataTable left,
                   DataTable right)
Creates new table with the left part defined by left and the appended right part given by right. If duplicate column names occur, an exception is thrown

Parameters:
left - the left part of the this table
right - and the corresponding right part
Throws:
IllegalArgumentException - if the tables contain the same column identifier
NullPointerException - if either table is null
IllegalArgumentException - if duplicate column names exist

JoinedTable

public JoinedTable(DataTable left,
                   DataTable right,
                   String duplicateMethod,
                   String suffix,
                   boolean inMemory)
Creates a new table with the left part defined by left and the appended right part given by right. Duplicate column names are treated as given by the duplicateMethod argument, i.e.

Parameters:
left - the left part of the this table
right - and the corresponding right part
duplicateMethod - the method on how to treat duplicates
suffix - the suffix that is used when the method is METHOD_APPEND_SUFFIX. In case of another any other method this argument is ignored.
inMemory - true if the tables should be joined in memory (faster but may need much memory)
Throws:
IllegalArgumentException - in case of duplicate column names and no special treatment is requested
NullPointerException - if either table is null
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 RowIterator 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
Returns:
row iterator
See Also:
DataRow

getLeftTable

protected DataTable getLeftTable()
Get reference to underlying left table.

Returns:
the reference

getRightTable

protected DataTable getRightTable()
Get reference to underlying right table.

Returns:
the reference

createSpec

public static final DataTableSpec createSpec(DataTableSpec left,
                                             DataTableSpec right)
Creates a new DataTableSpec as an result of merging a left and a right table. The method fails with an exception when there are duplicate column names

Parameters:
left - the left part of the this table
right - the corresponding right part
Returns:
the spec as result of merging both table specs
Throws:
IllegalArgumentException - in case of duplicate column names and no special treatment is requested
NullPointerException - if either table is null

createSpec

public static final DataTableSpec createSpec(DataTableSpec left,
                                             DataTableSpec right,
                                             String duplicateMethod,
                                             String suffix)
Creates a new DataTableSpec as an result of merging a left and a right table. Duplicate of column names are treated as given by the duplicateMethod argument, i.e.

Parameters:
left - the left part of the this table
right - and the corresponding right part
duplicateMethod - the method on how to treat duplicates
suffix - the suffix that is used when the method is METHOD_APPEND_SUFFIX. In case of another any other method this argument is ignored.
Returns:
the spec as result of merging both table specs
Throws:
IllegalArgumentException - in case of duplicate column names and no special treatment is requested
NullPointerException - if either table is null

isPrintedErrorOnMissing

boolean isPrintedErrorOnMissing()
Requested by iterated.

Returns:
the printedErrorOnMissing

setPrintedErrorOnMissing

void setPrintedErrorOnMissing(boolean printedErrorOnMissing)
Parameters:
printedErrorOnMissing - the printedErrorOnMissing to set

isPrintedErrorOnSorting

boolean isPrintedErrorOnSorting()
Requested by iterated.

Returns:
the printedErrorOnSorting

setPrintedErrorOnSorting

void setPrintedErrorOnSorting(boolean printedErrorOnSorting)
Parameters:
printedErrorOnSorting - the printedErrorOnSorting to set

createMissingCells

public static DataCell[] createMissingCells(DataTableSpec spec)
Fills an array with missing values according to the spec.

Parameters:
spec - the spec of the table
Returns:
an array of missing cells with the appropriate length and types
Throws:
IllegalStateException - if no missing cell can be instantiated


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.