Package com.mckoi.database
Class DefaultDataTable
- java.lang.Object
-
- com.mckoi.database.Table
-
- com.mckoi.database.AbstractDataTable
-
- com.mckoi.database.DefaultDataTable
-
- All Implemented Interfaces:
RootTable
,TableDataSource
- Direct Known Subclasses:
DataTable
,FunctionTable
,TemporaryTable
public abstract class DefaultDataTable extends AbstractDataTable
This represents a default implementation of a DataTable. It encapsulates information that is core to all DataTable objects. That is,The table name, The description of the table fields, A set of SelectableScheme objects to describe row relations, A counter for the number of rows in the table.
There are two classes that extend this object. DataTable which is a DataTable that is a direct mapping to an internal table stored in the Database files. And TemporaryTable that contains information generated on the fly by the DBMS.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.mckoi.database.Table
Table.TableVariableResolver
-
-
Field Summary
Fields Modifier and Type Field Description private SelectableScheme[]
column_scheme
A list of schemes for managing the data relations of each column.private Database
database
The Database object that this table is a child of.protected int
row_count
The number of rows in the table.-
Fields inherited from class com.mckoi.database.Table
DEBUG_QUERY
-
-
Constructor Summary
Constructors Constructor Description DefaultDataTable(Database database)
The Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addCellToColumnSchemes(int row_number, int column_number)
Adds a single column of a row to the selectable scheme indexing.(package private) void
addRowToColumnSchemes(int row_number)
This is called when a row is in the table, and the SelectableScheme objects for each column need to be notified of the rows existance, therefore build up the relational model for the columns.protected void
blankSelectableSchemes()
Blanks all the column schemes in the table to an initial state.protected void
blankSelectableSchemes(int type)
Blanks all the column schemes in this table to a specific type of scheme.protected void
clearColumnScheme(int column)
Clears the SelectableScheme information for the given column.int
findFieldName(Variable v)
Given a fully qualified variable field name, ie.int
getColumnCount()
Returns the number of columns in the table.Database
getDatabase()
Returns the Database object this table is part of.Variable
getResolvedVariable(int column)
Returns a fully qualified Variable object that represents the name of the column at the given index.protected SelectableScheme
getRootColumnScheme(int column)
Returns the SelectableScheme for the given column.int
getRowCount()
Returns the number of rows stored in the table.(package private) SelectableScheme
getSelectableSchemeFor(int column, int original_column, Table table)
Returns a SelectableScheme object for the given column of the VirtualTable.(package private) void
removeRowToColumnSchemes(int row_number)
This is called when an index to a row needs to be removed from the SelectableScheme objects.(package private) RawTableInformation
resolveToRawTable(RawTableInformation info)
Return the list of DataTable and row sets that make up the raw information in 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.-
Methods inherited from class com.mckoi.database.AbstractDataTable
getTableName, toString, typeEquals
-
Methods inherited from class com.mckoi.database.Table
addDataTableListener, all, allColumnMatchesValue, allRowsIn, allRowsNotIn, any, columnContainsCell, columnContainsValue, columnMatchesValue, columnMerge, compareCells, Debug, distinct, distinct, dumpTo, emptySelect, exhaustiveSelect, fastFindFieldName, getCellContents, getColumnDefAt, getColumnScheme, getDataTableDef, getFirstCellContent, getFirstCellContent, getLastCellContent, getLastCellContent, getSingleCellContent, getSingleCellContent, getSystem, getTableAccessState, getTTypeForColumn, getTTypeForColumn, getVariableResolver, hasRootsLocked, join, lockRoot, orderByColumn, orderByColumn, orderByColumn, orderByColumns, orderedRowList, outside, printGraph, rangeSelect, removeDataTableListener, rowEnumeration, selectAll, selectAll, selectFirst, selectFromPattern, selectFromRegex, selectLast, selectRange, selectRest, selectRows, selectRows, selectRows, simpleJoin, simpleSelect, singleRowSelect, toMap, union, unlockRoot
-
-
-
-
Field Detail
-
database
private Database database
The Database object that this table is a child of.
-
row_count
protected int row_count
The number of rows in the table.
-
column_scheme
private SelectableScheme[] column_scheme
A list of schemes for managing the data relations of each column.
-
-
Constructor Detail
-
DefaultDataTable
DefaultDataTable(Database database)
The Constructor.
-
-
Method Detail
-
getDatabase
public Database getDatabase()
Returns the Database object this table is part of.- Specified by:
getDatabase
in classTable
-
getRootColumnScheme
protected SelectableScheme getRootColumnScheme(int column)
Returns the SelectableScheme for the given column. This is different from 'getColumnScheme(int column)' because this is designed to be overridden so derived classes can manage their own SelectableScheme sources.
-
clearColumnScheme
protected void clearColumnScheme(int column)
Clears the SelectableScheme information for the given column.
-
blankSelectableSchemes
protected void blankSelectableSchemes()
Blanks all the column schemes in the table to an initial state. This will make all schemes of type InsertSearch.NOTE: The current default SelectableScheme type is InsertSearch. We may want to make this variable.
-
blankSelectableSchemes
protected void blankSelectableSchemes(int type)
Blanks all the column schemes in this table to a specific type of scheme. If Type = 0 then InsertSearch (fast but takes up memory - requires each insert and delete from the table to be logged). If type = 1 then BlindSearch (slower but uses no memory and doesn't require insert and delete to be logged).
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Specified by:
getColumnCount
in classTable
-
getRowCount
public int getRowCount()
Returns the number of rows stored in the table.- Specified by:
getRowCount
in interfaceTableDataSource
- Specified by:
getRowCount
in classTable
-
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")- Specified by:
getResolvedVariable
in classTable
-
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.- Specified by:
findFieldName
in classTable
-
getSelectableSchemeFor
SelectableScheme getSelectableSchemeFor(int column, int original_column, Table table)
Returns a SelectableScheme object for the given column of the VirtualTable. The Table parameter specifies the domain in which the scheme should be given. If table != this, we can safely assume it is a VirtualTable.- Specified by:
getSelectableSchemeFor
in classTable
-
setToRowTableDomain
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.- Specified by:
setToRowTableDomain
in classTable
-
resolveToRawTable
RawTableInformation resolveToRawTable(RawTableInformation info)
Return the list of DataTable and row sets that make up the raw information in this table. For a DataTable itselt, this is trivial. NOTE: Using this method is extremely inefficient, and should never be used. It is included only to complete feature set. IDEA: Put a warning to check if this method is ever used.- Specified by:
resolveToRawTable
in classTable
-
addCellToColumnSchemes
void addCellToColumnSchemes(int row_number, int column_number)
Adds a single column of a row to the selectable scheme indexing.
-
addRowToColumnSchemes
void addRowToColumnSchemes(int row_number)
This is called when a row is in the table, and the SelectableScheme objects for each column need to be notified of the rows existance, therefore build up the relational model for the columns.
-
removeRowToColumnSchemes
void removeRowToColumnSchemes(int row_number)
This is called when an index to a row needs to be removed from the SelectableScheme objects. This occurs when we have a modification log of row removals that haven't actually happened to old backed up scheme.
-
-