Package com.mckoi.database
Class SubsetColumnTable
- java.lang.Object
-
- com.mckoi.database.Table
-
- com.mckoi.database.FilterTable
-
- com.mckoi.database.SubsetColumnTable
-
- All Implemented Interfaces:
RootTable
,TableDataSource
public final class SubsetColumnTable extends FilterTable implements RootTable
This object is a filter that sits atop a Table object. Its purpose is to only provide a view of the columns that are required. In a Select query we may create a query with only the subset of columns that were originally in the table set. This object allows us to provide an interface to only the columns that the Table is allowed to access.This method implements RootTable which means a union operation will not decend further past this table when searching for the roots.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.mckoi.database.Table
Table.TableVariableResolver
-
-
Field Summary
Fields Modifier and Type Field Description private Variable[]
aliases
The resolved Variable aliases for this subset.private int[]
column_map
Maps from the column in this table to the column in the parent table.private int[]
reverse_column_map
Maps from the column in the parent table, to the column in this table.private DataTableDef
subset_table_def
The DataTableDef object that describes the subset column of this table.-
Fields inherited from class com.mckoi.database.FilterTable
parent
-
Fields inherited from class com.mckoi.database.Table
DEBUG_QUERY
-
-
Constructor Summary
Constructors Constructor Description SubsetColumnTable(Table parent)
The Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
findFieldName(Variable v)
Given a fully qualified variable field name, ie.TObject
getCellContents(int column, int row)
Returns an object that represents the information in the given cell in the table.int
getColumnCount()
Returns the number of columns in the table.DataTableDef
getDataTableDef()
Returns the DataTableDef object that describes the columns and name of this table.Variable
getResolvedVariable(int column)
Returns a fully qualified Variable object that represents the name of the column at the given index.(package private) SelectableScheme
getSelectableSchemeFor(int column, int original_column, Table table)
Returns a SelectableScheme for the given column in the given VirtualTable row domain.(package private) RawTableInformation
resolveToRawTable(RawTableInformation info)
Return the list of DataTable and row sets that make up the raw information in this table.void
setColumnMap(int[] mapping, Variable[] aliases)
Adds a column map into this table.(package private) void
setToRowTableDomain(int column, IntegerVector row_set, TableDataSource ancestor)
Given a set, this trickles down through the Table hierarchy resolving the given row_set to a form that the given ancestor understands.java.lang.String
toString()
Returns a string that represents this table.boolean
typeEquals(RootTable table)
This function is used to check that two tables are identical.-
Methods inherited from class com.mckoi.database.FilterTable
addDataTableListener, getDatabase, getParent, getRowCount, hasRootsLocked, lockRoot, printGraph, removeDataTableListener, rowEnumeration, unlockRoot
-
Methods inherited from class com.mckoi.database.Table
all, allColumnMatchesValue, allRowsIn, allRowsNotIn, any, columnContainsCell, columnContainsValue, columnMatchesValue, columnMerge, compareCells, Debug, distinct, distinct, dumpTo, emptySelect, exhaustiveSelect, fastFindFieldName, getColumnDefAt, getColumnScheme, getFirstCellContent, getFirstCellContent, getLastCellContent, getLastCellContent, getSingleCellContent, getSingleCellContent, getSystem, getTableAccessState, getTTypeForColumn, getTTypeForColumn, getVariableResolver, join, orderByColumn, orderByColumn, orderByColumn, orderByColumns, orderedRowList, outside, rangeSelect, selectAll, selectAll, selectFirst, selectFromPattern, selectFromRegex, selectLast, selectRange, selectRest, selectRows, selectRows, selectRows, simpleJoin, simpleSelect, singleRowSelect, toMap, union
-
-
-
-
Field Detail
-
column_map
private int[] column_map
Maps from the column in this table to the column in the parent table. The number of entries of this should match the number of columns in this table.
-
reverse_column_map
private int[] reverse_column_map
Maps from the column in the parent table, to the column in this table. The size of this should match the number of columns in the parent table.
-
subset_table_def
private DataTableDef subset_table_def
The DataTableDef object that describes the subset column of this table.
-
aliases
private Variable[] aliases
The resolved Variable aliases for this subset. These are returned by getResolvedVariable and used in searches for findResolvedVariable. This can be used to remap the variable names used to match the columns.
-
-
Constructor Detail
-
SubsetColumnTable
public SubsetColumnTable(Table parent)
The Constructor.
-
-
Method Detail
-
setColumnMap
public void setColumnMap(int[] mapping, Variable[] aliases)
Adds a column map into this table. The int array contains a map to the column in the parent object that we want the column number to reference. For example, to select columns 4, 8, 1, 2 into this new table, the array would be { 4, 8, 1, 2 }.
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Overrides:
getColumnCount
in classFilterTable
-
findFieldName
public int findFieldName(Variable v)
Given a fully qualified variable field name, ie. 'APP.CUSTOMER.CUSTOMERID' this will return the column number the field is at. Returns -1 if the field does not exist in the table.- Overrides:
findFieldName
in classFilterTable
-
getDataTableDef
public DataTableDef getDataTableDef()
Returns the DataTableDef object that describes the columns and name of this table. For a SubsetColumnTable object, this returns the columns that were mapped via the 'setColumnMap' method.- Specified by:
getDataTableDef
in interfaceTableDataSource
- Overrides:
getDataTableDef
in classFilterTable
-
getResolvedVariable
public Variable getResolvedVariable(int column)
Returns a fully qualified Variable object that represents the name of the column at the given index. For example, new Variable(new TableName("APP", "CUSTOMER"), "ID")- Overrides:
getResolvedVariable
in classFilterTable
-
getSelectableSchemeFor
final SelectableScheme getSelectableSchemeFor(int column, int original_column, Table table)
Returns a SelectableScheme for the given column in the given VirtualTable row domain.- Overrides:
getSelectableSchemeFor
in classFilterTable
-
setToRowTableDomain
final void setToRowTableDomain(int column, IntegerVector row_set, TableDataSource ancestor)
Given a set, this trickles down through the Table hierarchy resolving the given row_set to a form that the given ancestor understands. Say you give the set { 0, 1, 2, 3, 4, 5, 6 }, this function may check down three levels and return a new 7 element set with the rows fully resolved to the given ancestors domain.- Overrides:
setToRowTableDomain
in classFilterTable
-
resolveToRawTable
final RawTableInformation resolveToRawTable(RawTableInformation info)
Return the list of DataTable and row sets that make up the raw information in this table.- Overrides:
resolveToRawTable
in classFilterTable
-
getCellContents
public final TObject getCellContents(int column, int row)
Returns an object that represents the information in the given cell in the table. This will generally be an expensive algorithm, so calls to it should be kept to a minimum. Note that the offset between two rows is not necessarily 1.- Specified by:
getCellContents
in interfaceTableDataSource
- Overrides:
getCellContents
in classFilterTable
-
typeEquals
public boolean typeEquals(RootTable table)
This function is used to check that two tables are identical. This is used in operations like 'union' that need to determine that the roots are infact of the same type.- Specified by:
typeEquals
in interfaceRootTable
-
-