org.knime.base.node.preproc.rowkey
Class RowKeyUtil

java.lang.Object
  extended by org.knime.base.node.preproc.rowkey.RowKeyUtil

public class RowKeyUtil
extends Object

Provides methods to append a new row with the row key values or to replace the row key by the values of another column.

Author:
Tobias Koetter, University of Konstanz

Field Summary
protected static String MISSING_VALUE_REPLACEMENT
          This value is used instead of a missing value as new row key if the replaceMissingVals variable is set to true.
 
Constructor Summary
RowKeyUtil()
           
 
Method Summary
 BufferedDataTable changeRowKey(BufferedDataTable inData, ExecutionContext exec, String selRowKeyColName, boolean appendColumn, DataColumnSpec newColSpec, boolean ensureUniqueness, boolean replaceMissingVals, boolean removeRowKeyCol, boolean hiliteMap)
          Replaces the row key by the values of the column with the given name and appends a new column with the old key values if the newColName variable is a non empty String.
static ColumnRearranger createColumnRearranger(DataTableSpec inSpec, String newColName, DataType type)
          Creates the ColumnRearranger that appends a new column with the values of the row id to a data table.
static DataTableSpec createTableSpec(DataTableSpec spec, String... columnNames2Drop)
           
 int getDuplicatesCounter()
           
 Map<RowKey,Set<RowKey>> getHiliteMapping()
          The hilite translation Map or null if the enableHilte flag in the constructor was set to false.
 int getMissingValueCounter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MISSING_VALUE_REPLACEMENT

protected static final String MISSING_VALUE_REPLACEMENT
This value is used instead of a missing value as new row key if the replaceMissingVals variable is set to true.

See Also:
Constant Field Values
Constructor Detail

RowKeyUtil

public RowKeyUtil()
Method Detail

createColumnRearranger

public static ColumnRearranger createColumnRearranger(DataTableSpec inSpec,
                                                      String newColName,
                                                      DataType type)
Creates the ColumnRearranger that appends a new column with the values of the row id to a data table.

Parameters:
inSpec - the DataTableSpec of table were the column should be appended
newColName - the name of the added column
type - the DataType of the new column
Returns:
the ColumnRearranger to use

changeRowKey

public BufferedDataTable changeRowKey(BufferedDataTable inData,
                                      ExecutionContext exec,
                                      String selRowKeyColName,
                                      boolean appendColumn,
                                      DataColumnSpec newColSpec,
                                      boolean ensureUniqueness,
                                      boolean replaceMissingVals,
                                      boolean removeRowKeyCol,
                                      boolean hiliteMap)
                               throws Exception

Replaces the row key by the values of the column with the given name and appends a new column with the old key values if the newColName variable is a non empty String.

Call the getDuplicatesCounter() and getMissingValueCounter() methods to get information about the replaced duplicates and missing values after this method is completed.

Parameters:
inData - The BufferedDataTable with the input data
exec - the ExecutionContext to check for cancel and to provide status messages
selRowKeyColName - the name of the column which should replace the row key or null if a new one should be created
appendColumn - true if a new column should be created
newColSpec - the DataColumnSpec of the new column or null if no column should be created at all
ensureUniqueness - if set to true the method ensures the uniqueness of the row key even if the values of the selected row aren't unique
replaceMissingVals - if set to true the method replaces missing values with ?
removeRowKeyCol - removes the selected row key column if set to true
hiliteMap - true if a map should be maintained that maps the new row id to the old row id
Returns:
the BufferedDataTable with the replaced row key and the optional appended new column with the old row keys.
Throws:
Exception - if the cancel button was pressed or the input data isn't valid.

getMissingValueCounter

public int getMissingValueCounter()
Returns:
the number of missing values which were found while changing the row key

getDuplicatesCounter

public int getDuplicatesCounter()
Returns:
the number of duplicates which were found while changing the row key

getHiliteMapping

public Map<RowKey,Set<RowKey>> getHiliteMapping()
The hilite translation Map or null if the enableHilte flag in the constructor was set to false. The key of the Map is the row key of the new row and the corresponding value is the Set with the corresponding old row key.

Returns:
the hilite translation Map or null if the enableHilte flag in the constructor was set to false.

createTableSpec

public static DataTableSpec createTableSpec(DataTableSpec spec,
                                            String... columnNames2Drop)
Parameters:
spec - the original DataTableSpec
columnNames2Drop - the names of the column to remove from the original table specification
Returns:
the original table specification without the column specifications of the given names


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.