Package com.mckoi.database
Class VirtualTable
- java.lang.Object
-
- com.mckoi.database.Table
-
- com.mckoi.database.JoinedTable
-
- com.mckoi.database.VirtualTable
-
- All Implemented Interfaces:
TableDataSource
- Direct Known Subclasses:
OuterTable
public class VirtualTable extends JoinedTable
A VirtualTable is a representation of a table whose rows are actually physically stored in another table. In other words, this table just stores pointers to rows in other tables.We use the VirtualTable to represent temporary tables created from select, join, etc operations.
An important note about VirtualTables: When we perform a 'select' operation on a virtual table, unlike a DataTable that permanently stores information about column cell relations, we must resolve column relations between the sub-set at select time. This involves asking the tables parent(s) for a scheme to describe relations in a sub-set.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.mckoi.database.Table
Table.TableVariableResolver
-
-
Field Summary
Fields Modifier and Type Field Description private int
row_count
The number of rows in the table.protected IntegerVector[]
row_list
Array of IntegerVectors that represent the rows taken from the given parents.-
Fields inherited from class com.mckoi.database.JoinedTable
column_filter, column_scheme, column_table, reference_list
-
Fields inherited from class com.mckoi.database.Table
DEBUG_QUERY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
VirtualTable()
(package private)
VirtualTable(Table table)
(package private)
VirtualTable(Table[] tables)
The Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IntegerVector[]
getReferenceRows()
Returns the list of IntegerVector that represents the rows that this VirtualTable references.int
getRowCount()
Returns the number of rows stored in the table.protected void
init(Table[] tables)
Helper function for the constructor.protected void
resolveAllRowsForTableAt(IntegerVector row_set, int table_num)
Given an IntegerVector that represents a list of pointers to rows in this table, this resolves the rows to row indexes in the given parent table.protected int
resolveRowForTableAt(int row_number, int table_num)
Given a row and a table index (to a parent reference table), this will return the row index in the given parent table for the given row.(package private) void
set(Table[] tables, BlockIntegerList[] rows)
Sets the rows in this table as above, but uses a BlockIntegerList array as an argument instead.(package private) void
set(Table[] tables, IntegerVector[] rows)
This is used in a join to set a list or joined rows and tables.(package private) void
set(Table table, BlockIntegerList rows)
Sets the rows in this table as above, but uses a BlockIntegerList as an argument instead.(package private) void
set(Table table, IntegerVector rows)
Sets the rows in this table.-
Methods inherited from class com.mckoi.database.JoinedTable
addDataTableListener, findFieldName, getCellContents, getColumnCount, getDatabase, getDataTableDef, getReferenceTables, getResolvedVariable, getSelectableSchemeFor, hasRootsLocked, lockRoot, optimisedPostSet, printGraph, removeDataTableListener, resolveToRawTable, resolveToRawTable, rowEnumeration, setToRowTableDomain, 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, toString, union
-
-
-
-
Field Detail
-
row_list
protected IntegerVector[] row_list
Array of IntegerVectors that represent the rows taken from the given parents.
-
row_count
private int row_count
The number of rows in the table.
-
-
Method Detail
-
init
protected void init(Table[] tables)
Helper function for the constructor.- Overrides:
init
in classJoinedTable
-
getReferenceRows
protected IntegerVector[] getReferenceRows()
Returns the list of IntegerVector that represents the rows that this VirtualTable references.
-
getRowCount
public int getRowCount()
Returns the number of rows stored in the table.- Specified by:
getRowCount
in interfaceTableDataSource
- Specified by:
getRowCount
in classTable
-
set
void set(Table table, IntegerVector rows)
Sets the rows in this table. We should search for the 'table' in the 'reference_list' however we don't for efficiency.
-
set
void set(Table[] tables, IntegerVector[] rows)
This is used in a join to set a list or joined rows and tables. The 'tables' array should be an exact mirror of the 'reference_list'. The IntegerVector[] array contains the rows to add for each respective table. The given IntegerVector objects should have identical lengths.
-
set
void set(Table table, BlockIntegerList rows)
Sets the rows in this table as above, but uses a BlockIntegerList as an argument instead.
-
set
void set(Table[] tables, BlockIntegerList[] rows)
Sets the rows in this table as above, but uses a BlockIntegerList array as an argument instead.
-
resolveRowForTableAt
protected int resolveRowForTableAt(int row_number, int table_num)
Description copied from class:JoinedTable
Given a row and a table index (to a parent reference table), this will return the row index in the given parent table for the given row.- Specified by:
resolveRowForTableAt
in classJoinedTable
-
resolveAllRowsForTableAt
protected void resolveAllRowsForTableAt(IntegerVector row_set, int table_num)
Description copied from class:JoinedTable
Given an IntegerVector that represents a list of pointers to rows in this table, this resolves the rows to row indexes in the given parent table. This method changes the 'row_set' IntegerVector object.- Specified by:
resolveAllRowsForTableAt
in classJoinedTable
-
-