org.knime.base.data.sort
Class SortedTable

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

public class SortedTable
extends Object
implements DataTable

A data table that sorts a given data table according to the passed sorting parameters.

Author:
Christoph Sieb, University of Konstanz, Nicolas Cebron, University of Konstanz

Constructor Summary
SortedTable(BufferedDataTable dataTable, Comparator<DataRow> rowComparator, boolean sortInMemory, ExecutionContext exec)
          Creates a new sorted table.
SortedTable(BufferedDataTable dataTable, List<String> inclList, boolean[] sortAscending, boolean sortInMemory, ExecutionContext exec)
          Creates a sorted table from the given table and the sorting parameters.
SortedTable(BufferedDataTable dataTable, List<String> inclList, boolean[] sortAscending, ExecutionContext exec)
          Creates a sorted table from the given table and the sorting parameters.
 
Method Summary
 BufferedDataTable getBufferedDataTable()
           
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 int getRowCount()
           
 RowIterator iterator()
          Returns a row iterator which returns each row one-by-one from the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedTable

public SortedTable(BufferedDataTable dataTable,
                   Comparator<DataRow> rowComparator,
                   boolean sortInMemory,
                   ExecutionContext exec)
            throws CanceledExecutionException
Creates a new sorted table. Sorting is done with the given comparator.

Parameters:
dataTable - any data table
rowComparator - the comparator that should be used for sorting
sortInMemory - true if sorting should be done in memory, false if sorting should be done on disk
exec - an execution context for reporting progress and creating temporary table files
Throws:
CanceledExecutionException - if the user canceled execution

SortedTable

public SortedTable(BufferedDataTable dataTable,
                   List<String> inclList,
                   boolean[] sortAscending,
                   ExecutionContext exec)
            throws CanceledExecutionException
Creates a sorted table from the given table and the sorting parameters. The table is sorted in the constructor.

Parameters:
dataTable - the buffered data table to sort
inclList - the list with the columns to sort; the first column name represents the first sort criteria, the second the second criteria and so on.
sortAscending - the sort order; each field corresponds to the column in the list of included columns. true: ascending false: descending
exec - the execution context used to create the the buffered data table and indicate the progress
Throws:
CanceledExecutionException - the user has canceled this operation

SortedTable

public SortedTable(BufferedDataTable dataTable,
                   List<String> inclList,
                   boolean[] sortAscending,
                   boolean sortInMemory,
                   ExecutionContext exec)
            throws CanceledExecutionException
Creates a sorted table from the given table and the sorting parameters. The table is sorted in the constructor.

Parameters:
dataTable - the buffered data table to sort
inclList - the list with the columns to sort; the first column name represents the first sort criteria, the second the second criteria and so on.
sortAscending - the sort order; each field corresponds to the column in the list of included columns. true: ascending false: descending
sortInMemory - true if the table should be sorted in memory, false if it should be sorted in disk. Sorting in memory is much faster but may fail if the data table is too big.
exec - the execution context used to create the the buffered data table and indicate the progress
Throws:
CanceledExecutionException - the user has canceled this operation
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

getBufferedDataTable

public BufferedDataTable getBufferedDataTable()
Returns:
the sorted table as buffered data table

getRowCount

public int getRowCount()
Returns:
the number of rows of this table


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.