Package uk.ac.starlink.table
Class CalcStarTable<C>
- java.lang.Object
-
- uk.ac.starlink.table.AbstractStarTable
-
- uk.ac.starlink.table.CalcStarTable<C>
-
- Type Parameters:
C
- type of object that is calculated from each row of the input table, and supplies values to the corresponding row of this table
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,StarTable
public abstract class CalcStarTable<C> extends AbstractStarTable
StarTable implementation whose column values are derived from some single calculation on the column values of another table. The idea is that the cell values in a given row of an instance of this table are cheaply-obtained members of an object which is obtained by a potentially expensive calculation on the cell values of the corresponding row in the other table.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CalcStarTable.Col<C,T>
Defines a column for use with this table implementation.
-
Constructor Summary
Constructors Constructor Description CalcStarTable(StarTable base, CalcStarTable.Col<C,?>[] columns)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract C
createCalculation(long irow)
Creates the calculation object for the given row of the input table.abstract C
createCalculation(RowData baseRow)
Creates the calculation object for the current row of the input table.StarTable
getBaseTable()
Returns the input table on which this table is based.java.lang.Object
getCell(long irow, int icol)
The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.int
getColumnCount()
Returns the number of columns in this table.ColumnInfo
getColumnInfo(int icol)
Returns the object describing the data in a given column.java.lang.Object[]
getRow(long irow)
The AbstractStarTable implementation of this method constructs a row by repeated invocation ofAbstractStarTable.getCell(long, int)
.RowAccess
getRowAccess()
Returns an object which can provide random access to this table's data, if random access is implemented.long
getRowCount()
Returns the number of rows in this table, if known.RowSequence
getRowSequence()
Returns an object which can iterate over all the rows in the table sequentially.RowSplittable
getRowSplittable()
Returns a default splittable which relies on table random access if available, or otherwise provides only sequential access (no splits).boolean
isRandom()
The AbstractStarTable implementation of this method returns false.-
Methods inherited from class uk.ac.starlink.table.AbstractStarTable
checkedLongToInt, close, getColumnAuxDataInfos, getName, getParameters, getURL, setName, setParameters, setURL
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.starlink.table.StarTable
getParameterByName, setParameter
-
-
-
-
Constructor Detail
-
CalcStarTable
public CalcStarTable(StarTable base, CalcStarTable.Col<C,?>[] columns)
Constructor.- Parameters:
base
- input tablecolumns
- array defining the columns of this table
-
-
Method Detail
-
createCalculation
public abstract C createCalculation(RowData baseRow) throws java.io.IOException
Creates the calculation object for the current row of the input table.- Parameters:
baseRow
- row from base table- Returns:
- calculation object corresponding to
baseRow
- Throws:
java.io.IOException
-
createCalculation
public abstract C createCalculation(long irow) throws java.io.IOException
Creates the calculation object for the given row of the input table. Only works for random-access tables.- Parameters:
irow
- row index for which calculation is required- Returns:
- calculation object for input table row
irow
- Throws:
java.io.IOException
-
getBaseTable
public StarTable getBaseTable()
Returns the input table on which this table is based.- Returns:
- base table
-
getColumnInfo
public ColumnInfo getColumnInfo(int icol)
Description copied from interface:StarTable
Returns the object describing the data in a given column.- Specified by:
getColumnInfo
in interfaceStarTable
- Specified by:
getColumnInfo
in classAbstractStarTable
- Parameters:
icol
- the column for which header information is required- Returns:
- a ValueInfo object for column icol
-
getColumnCount
public int getColumnCount()
Description copied from interface:StarTable
Returns the number of columns in this table.- Specified by:
getColumnCount
in interfaceStarTable
- Specified by:
getColumnCount
in classAbstractStarTable
- Returns:
- the number of columns
-
getRowCount
public long getRowCount()
Description copied from interface:StarTable
Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.- Specified by:
getRowCount
in interfaceStarTable
- Specified by:
getRowCount
in classAbstractStarTable
- Returns:
- the number of rows, or -1
-
isRandom
public boolean isRandom()
Description copied from class:AbstractStarTable
The AbstractStarTable implementation of this method returns false.- Specified by:
isRandom
in interfaceStarTable
- Overrides:
isRandom
in classAbstractStarTable
- Returns:
- true if table random access methods are available
-
getRowSequence
public RowSequence getRowSequence() throws java.io.IOException
Description copied from interface:StarTable
Returns an object which can iterate over all the rows in the table sequentially. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.- Specified by:
getRowSequence
in interfaceStarTable
- Specified by:
getRowSequence
in classAbstractStarTable
- Returns:
- new RowSequence
- Throws:
java.io.IOException
- if there is an error providing access
-
getRowSplittable
public RowSplittable getRowSplittable() throws java.io.IOException
Description copied from class:AbstractStarTable
Returns a default splittable which relies on table random access if available, or otherwise provides only sequential access (no splits).It is often possible to provide a better implementation than this.
- Specified by:
getRowSplittable
in interfaceStarTable
- Overrides:
getRowSplittable
in classAbstractStarTable
- Returns:
Tables.getDefaultRowSplittable(this)
- Throws:
java.io.IOException
- See Also:
RowRunner
-
getRowAccess
public RowAccess getRowAccess() throws java.io.IOException
Description copied from interface:StarTable
Returns an object which can provide random access to this table's data, if random access is implemented. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.- Specified by:
getRowAccess
in interfaceStarTable
- Overrides:
getRowAccess
in classAbstractStarTable
- Returns:
- new RowAccess
- Throws:
java.io.IOException
- if there is an error setting up access
-
getRow
public java.lang.Object[] getRow(long irow) throws java.io.IOException
Description copied from class:AbstractStarTable
The AbstractStarTable implementation of this method constructs a row by repeated invocation ofAbstractStarTable.getCell(long, int)
.- Specified by:
getRow
in interfaceStarTable
- Overrides:
getRow
in classAbstractStarTable
- Parameters:
irow
- the index of the row to retrieve- Returns:
- an array of the objects in each cell in row irow
- Throws:
java.io.IOException
- if there is an error reading the data
-
getCell
public java.lang.Object getCell(long irow, int icol) throws java.io.IOException
Description copied from class:AbstractStarTable
The AbstractStarTable implementation of this method throws an UnsupportedOperationException, since unless otherwise provided there is no random access.- Specified by:
getCell
in interfaceStarTable
- Overrides:
getCell
in classAbstractStarTable
- Parameters:
irow
- the index of the cell's rowicol
- the index of the cell's column- Returns:
- the contents of this cell
- Throws:
java.io.IOException
- if there is an error reading the data
-
-