| java.lang.Object com.mckoi.database.Table com.mckoi.database.AbstractDataTable com.mckoi.database.DefaultDataTable com.mckoi.database.DataTable
DataTable | final public class DataTable extends DefaultDataTable (Code) | | DataTable is a wrapper for a MutableTableDataSource that fits into the
query hierarchy level. A DataTable represents a table within a
transaction. Adding, removing rows to a DataTable will change the
contents only with the context of the transaction the table was created in.
author: Tobias Downer |
Field Summary | |
final static boolean | LOCK_DEBUG ------
NOTE: Following values are only kept for lock debugging reasons. |
Method Summary | |
final public DebugLogger | Debug() Convenience - used to log debug messages. | final public void | add(RowData row_data) Adds a given 'RowData' object to the table. | final public void | add(RowData[] row_data_arr) Adds an array of 'RowData' objects to the table. | public void | addDataTableListener(DataTableListener listener) Adds a DataTableListener to the DataTable objects at the root of this
table tree hierarchy. | protected void | blankSelectableSchemes(int type) Overwritten from DefaultDataTable to do nothing. | final public RowData | createRowDataObject(QueryContext context) Generates an empty RowData object for 'addRow'ing into the Table. | public ReferenceTable | declareAs(TableName new_name) We can declare a DataTable as a new type. | public int | delete(Table table, int limit) This is the public method for removing a given result set from this
table. | public int | delete(Table table) | public int | findFieldName(Variable v) | public TObject | getCellContents(int column, int row) Returns an object that represents the information in the given cell
in the table. | public int | getColumnCount() | public DataTableDef | getDataTableDef() Returns the DataTableDef object for this table. | public Variable | getResolvedVariable(int column) | protected SelectableScheme | getRootColumnScheme(int column) Returns the SelectableScheme for the given column.
(Overridden from DefaultDataTable). | public int | getRowCount() Returns the current row count. | public String | getSchema() Returns the schema that this table is within. | SelectableScheme | getSelectableSchemeFor(int column, int original_column, Table table) | public boolean | hasRootsLocked() Returns true if the table has its row roots locked (via the lockRoot(int)
method. | public void | lockRoot(int lock_key) Locks the root table(s) of this table so that it is impossible to
overwrite the underlying rows that may appear in this table.
This is used when cells in the table need to be accessed 'outside' the
lock. | final void | notifyAddRWLock(int lock_type) This is called by the 'Lock' class to notify this DataTable that a read/
write lock has been applied to this table. | final void | notifyReleaseRWLock(int lock_type) This is called by the 'Lock' class to notify this DataTable that a read/
write lock has been released from this table. | public void | removeDataTableListener(DataTableListener listener) Removes a DataTableListener from the DataTable objects at the root of
this table tree hierarchy. | RawTableInformation | resolveToRawTable(RawTableInformation info) | public RowEnumeration | rowEnumeration() Returns an Enumeration of the rows in this table. | 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. | public void | unlockRoot(int lock_key) Unlocks the root tables so that the underlying rows may
once again be used if they are not locked and have been removed. | final public int | update(QueryContext context, Table table, Assignment[] assign_list, int limit) Updates the table by applying the assignment operations over each row
that is found in the input 'table' set. |
LOCK_DEBUG | final static boolean LOCK_DEBUG(Code) | | ------
NOTE: Following values are only kept for lock debugging reasons. These
is no technical reason why they shouldn't be removed. They allow us
to check that a data table is locked correctly when accesses are
performed on it.
------
|
Debug | final public DebugLogger Debug()(Code) | | Convenience - used to log debug messages.
|
add | final public void add(RowData row_data) throws DatabaseException(Code) | | Adds a given 'RowData' object to the table. This should be used for
any rows added to the table. The order that rows are added into a table
is not important.
This method performs some checking of the cells in the table. It first
checks that all columns declared as 'not null' have a value that is not
null. It then checks that a the added row will not cause any duplicates
in a column declared as unique.
It then uses the low level io manager to store the data.
SYNCHRONIZATION ISSUE: We are assuming this is running in a synchronized
environment that is unable to add or alter rows in this object within
the lifetime of this method.
|
add | final public void add(RowData[] row_data_arr) throws DatabaseException(Code) | | Adds an array of 'RowData' objects to the table. This should be used for
adding a group of rows to the table. The order that rows are added into
a table is not important.
This method performs some checking of the cells in the table. It first
checks that all columns declared as 'not null' have a value that is not
null. It then checks that a the added row will not cause any duplicates
in a column declared as unique.
It then uses the low level io manager to store the data.
SYNCHRONIZATION ISSUE: We are assuming this is running in a synchronized
environment that is unable to add or alter rows in this object within
the lifetime of this method.
|
addDataTableListener | public void addDataTableListener(DataTableListener listener)(Code) | | Adds a DataTableListener to the DataTable objects at the root of this
table tree hierarchy. If this table represents the join of a number of
tables then the DataTableListener is added to all the DataTable objects
at the root.
A DataTableListener is notified of all modifications to the raw entries
of the table. This listener can be used for detecting changes in VIEWs,
for triggers or for caching of common queries.
|
blankSelectableSchemes | protected void blankSelectableSchemes(int type)(Code) | | Overwritten from DefaultDataTable to do nothing. All selectable
schemes are handled within the DataTableManager now.
|
createRowDataObject | final public RowData createRowDataObject(QueryContext context)(Code) | | Generates an empty RowData object for 'addRow'ing into the Table.
We must first call this method to retrieve a blank RowData object,
fill it in with the required information, and then call 'addRow'
|
declareAs | public ReferenceTable declareAs(TableName new_name)(Code) | | We can declare a DataTable as a new type. This means, instead of
referencing a column as 'Customer.CustomerID' we can change the 'Customer'
part to anything we wish such as 'C1'.
|
delete | public int delete(Table table, int limit) throws DatabaseException(Code) | | This is the public method for removing a given result set from this
table. Given a Table object, this will remove from this table any row
that are in the given table. The given Table must have this object as
its distant ancestor. If it does not then it will throw an exception.
Examples: table.delete(table) -- delete the entire table.
table.delete(table.select( < some condition > ));
It returns the number of rows that were deleted.
INTERNAL NOTE: The 'table' parameter may be the result
of joins. This may cause the same row in this table to be referenced
more than once. We must make sure that we delete any given row only
once by using the 'distinct' function.
'limit' dictates how many rows will be deleted. If 'limit' is less than
0 then this indicates there is no limit. Keep in mind that rows are
picked out from top to bottom in the 'table' object. Normally the
input table will be the result of an un-ordered 'where' clause so using
a limit does not permit deletes in a deterministic manner.
ASSUMPTION: There are no duplicate rows in the input set.
|
getCellContents | public TObject getCellContents(int column, int row)(Code) | | Returns an object that represents the information in the given cell
in the table. This can be used to obtain information about the given
table cells.
|
getColumnCount | public int getColumnCount()(Code) | | |
getDataTableDef | public DataTableDef getDataTableDef()(Code) | | Returns the DataTableDef object for this table. This object describes
how the table is made up.
NOTE: Do not keep references to this object. The
DataTableDef is invalidated when a table is closed.
|
getResolvedVariable | public Variable getResolvedVariable(int column)(Code) | | |
getRootColumnScheme | protected SelectableScheme getRootColumnScheme(int column)(Code) | | Returns the SelectableScheme for the given column.
(Overridden from DefaultDataTable). If the schemes are not in memory then
they are loaded now. This will synchronize over the 'table_manager'
which will effectively block this table at the lowest layer until the
indices are loaded into memory.
|
getRowCount | public int getRowCount()(Code) | | Returns the current row count. This queries the DataTableManager for
the real value.
|
getSchema | public String getSchema()(Code) | | Returns the schema that this table is within.
|
hasRootsLocked | public boolean hasRootsLocked()(Code) | | Returns true if the table has its row roots locked (via the lockRoot(int)
method.
|
lockRoot | public void lockRoot(int lock_key)(Code) | | Locks the root table(s) of this table so that it is impossible to
overwrite the underlying rows that may appear in this table.
This is used when cells in the table need to be accessed 'outside' the
lock. So we may have late access to cells in the table.
'lock_key' is a given key that will also unlock the root table(s).
NOTE: This is nothing to do with the 'LockingMechanism' object.
|
notifyAddRWLock | final void notifyAddRWLock(int lock_type)(Code) | | This is called by the 'Lock' class to notify this DataTable that a read/
write lock has been applied to this table. This is for lock debugging
purposes only.
|
notifyReleaseRWLock | final void notifyReleaseRWLock(int lock_type)(Code) | | This is called by the 'Lock' class to notify this DataTable that a read/
write lock has been released from this table. This is for lock debugging
purposes only.
|
removeDataTableListener | public void removeDataTableListener(DataTableListener listener)(Code) | | Removes a DataTableListener from the DataTable objects at the root of
this table tree hierarchy. If this table represents the join of a
number of tables, then the DataTableListener is removed from all the
DataTable objects at the root.
|
rowEnumeration | public RowEnumeration rowEnumeration()(Code) | | Returns an Enumeration of the rows in this table.
Each call to 'nextRowIndex' returns the next valid row index in the table.
|
setToRowTableDomain | void setToRowTableDomain(int column, IntegerVector row_set, TableDataSource ancestor)(Code) | | 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.
|
unlockRoot | public void unlockRoot(int lock_key)(Code) | | Unlocks the root tables so that the underlying rows may
once again be used if they are not locked and have been removed. This
should be called some time after the rows have been locked.
|
update | final public int update(QueryContext context, Table table, Assignment[] assign_list, int limit) throws DatabaseException(Code) | | Updates the table by applying the assignment operations over each row
that is found in the input 'table' set. The input table must be a direct
child of this DataTable.
This operation assumes that there is a WRITE lock on this table. A
WRITE lock means no other thread may access this table while the
operation is being performed. (However, a result set may still be
downloading from this table).
'limit' dictates how many rows will be updated. If 'limit' is less than
0 then this indicates there is no limit. Keep in mind that rows are
picked out from top to bottom in the 'table' object. Normally the
input table will be the result of an un-ordered 'where' clause so using
a limit does not permit updates in a deterministic manner.
Returns the number of rows updated in this table.
NOTE: We assume there are no duplicate rows to the root set from the
given 'table'.
|
Fields inherited from com.mckoi.database.DefaultDataTable | protected int row_count(Code)(Java Doc)
|
Fields inherited from com.mckoi.database.Table | protected static boolean DEBUG_QUERY(Code)(Java Doc)
|
Methods inherited from com.mckoi.database.Table | public DebugLogger Debug()(Code)(Java Doc) abstract void addDataTableListener(DataTableListener listener)(Code)(Java Doc) public Table all(QueryContext context, Expression lhs, Operator op, Table table)(Code)(Java Doc) final public boolean allColumnMatchesValue(int column, Operator op, TObject ob)(Code)(Java Doc) final IntegerVector allRowsIn(int column, Table table)(Code)(Java Doc) final IntegerVector allRowsNotIn(int column, Table table)(Code)(Java Doc) public Table any(QueryContext context, Expression lhs, Operator op, Table right_table)(Code)(Java Doc) final public boolean columnContainsCell(int column, TObject cell)(Code)(Java Doc) final public boolean columnContainsValue(int column, TObject ob)(Code)(Java Doc) final public boolean columnMatchesValue(int column, Operator op, TObject ob)(Code)(Java Doc) final public Table columnMerge(Table table)(Code)(Java Doc) public static boolean compareCells(TObject ob1, TObject ob2, Operator op)(Code)(Java Doc) final public VirtualTable distinct()(Code)(Java Doc) final public Table distinct(int[] col_map)(Code)(Java Doc) final public void dumpTo(PrintStream out) throws IOException(Code)(Java Doc) final public Table emptySelect()(Code)(Java Doc) final public Table exhaustiveSelect(QueryContext context, Expression exp)(Code)(Java Doc) final public int fastFindFieldName(Variable col)(Code)(Java Doc) abstract public int findFieldName(Variable v)(Code)(Java Doc) abstract public TObject getCellContents(int column, int row)(Code)(Java Doc) abstract public int getColumnCount()(Code)(Java Doc) public DataTableColumnDef getColumnDefAt(int col_index)(Code)(Java Doc) public SelectableScheme getColumnScheme(int column)(Code)(Java Doc) abstract public DataTableDef getDataTableDef()(Code)(Java Doc) abstract public Database getDatabase()(Code)(Java Doc) final public TObject getFirstCellContent(int column)(Code)(Java Doc) final public TObject[] getFirstCellContent(int[] col_map)(Code)(Java Doc) final public TObject getLastCellContent(int column)(Code)(Java Doc) final public TObject[] getLastCellContent(int[] col_map)(Code)(Java Doc) abstract public Variable getResolvedVariable(int column)(Code)(Java Doc) abstract public int getRowCount()(Code)(Java Doc) abstract SelectableScheme getSelectableSchemeFor(int column, int original_column, Table table)(Code)(Java Doc) final public TObject getSingleCellContent(int column)(Code)(Java Doc) final public TObject[] getSingleCellContent(int[] col_map)(Code)(Java Doc) final public TransactionSystem getSystem()(Code)(Java Doc) public TType getTTypeForColumn(int column)(Code)(Java Doc) public TType getTTypeForColumn(Variable v)(Code)(Java Doc) final public TableAccessState getTableAccessState()(Code)(Java Doc) final TableVariableResolver getVariableResolver()(Code)(Java Doc) abstract public boolean hasRootsLocked()(Code)(Java Doc) final public Table join(Table table)(Code)(Java Doc) abstract public void lockRoot(int lock_key)(Code)(Java Doc) final public VirtualTable orderByColumn(int col_index, boolean ascending)(Code)(Java Doc) final public VirtualTable orderByColumn(Variable column, boolean ascending)(Code)(Java Doc) final public VirtualTable orderByColumn(Variable column)(Code)(Java Doc) final public Table orderByColumns(int[] col_map)(Code)(Java Doc) final public IntegerVector orderedRowList(int[] col_map)(Code)(Java Doc) final public VirtualTable outside(Table rtable)(Code)(Java Doc) public void printGraph(PrintStream out, int indent)(Code)(Java Doc) final public Table rangeSelect(Variable col_var, SelectableRange[] ranges)(Code)(Java Doc) abstract void removeDataTableListener(DataTableListener listener)(Code)(Java Doc) abstract RawTableInformation resolveToRawTable(RawTableInformation info)(Code)(Java Doc) abstract public RowEnumeration rowEnumeration()(Code)(Java Doc) final public IntegerVector selectAll(int column)(Code)(Java Doc) final public IntegerVector selectAll()(Code)(Java Doc) final public IntegerVector selectFirst(int column)(Code)(Java Doc) final IntegerVector selectFromPattern(int column, Operator op, TObject ob)(Code)(Java Doc) final IntegerVector selectFromRegex(int column, Operator op, TObject ob)(Code)(Java Doc) final public IntegerVector selectLast(int column)(Code)(Java Doc) final public IntegerVector selectRange(int column, SelectableRange[] ranges)(Code)(Java Doc) final public IntegerVector selectRest(int column)(Code)(Java Doc) final IntegerVector selectRows(int[] cols, Operator op, TObject[] cells)(Code)(Java Doc) final IntegerVector selectRows(int column, Operator op, TObject cell)(Code)(Java Doc) IntegerVector selectRows(int column, TObject min_cell, TObject max_cell)(Code)(Java Doc) abstract void setToRowTableDomain(int column, IntegerVector row_set, TableDataSource ancestor)(Code)(Java Doc) final public Table simpleJoin(QueryContext context, Table table, Variable lhs_var, Operator op, Expression rhs)(Code)(Java Doc) final public Table simpleSelect(QueryContext context, Variable lhs_var, Operator op, Expression rhs)(Code)(Java Doc) final public Table singleRowSelect(int row_index)(Code)(Java Doc) public Map toMap()(Code)(Java Doc) public String toString()(Code)(Java Doc) final public Table union(Table table)(Code)(Java Doc) abstract public void unlockRoot(int lock_key)(Code)(Java Doc)
|
|
|