com.mckoi.database |
com.mckoi.database - The core database classes for Mckoi
The core database classes for Mckoi.
Data Representation
A database is represented by a single
TableDataConglomerate,
which contains a collection of
MasterTableDataSource objects,
each of which represents a single table, including both committed and
uncommitted rows.
Access to a table is usually through the
TableDataSource interface, or its subclass
MutableTableDataSource
The
MasterTableDataSource objects
wrap themselves in an instance of the private class
MasterTableDataSource.MMutableTableDataSource, which implements
MutableTableDataSource.
The format of a table is defined by
DataTableDef, which is returned by
TableDataSource.getDataTableDef,
and which does not change during the lifetime of the table;
if the table format is changed, a new MasterTableDataSource is created
within the Transaction with the new format,
and the data and unchanged columns from the old table
are copied to the new one.
The format of a column is defined by
DataTableColumnDef.
Modifications to a row of a table are handled by a
RowData, which carries a reference to the
TableDataSource which it modified,
and from which data is retrieved.
Each column within the row is represented by a
DataCell,
which is either retrieved from the table or created by
DataCellFactory.
Transactions
A database can be associated with one or more simultaneous
Transaction objects.
All changes to the data in the database are done through Transactions.
The current set of open Transaction objects is managed by an
OpenTransactionList object,
which is pointed to by both the
TableDataConglomerate
and all of the
MasterTableDataSource
objects.
Changes to a row are handled by creating a new row in the
MasterTableDataSource
containing the changed
data plus any old data which is unchanged.
The data for the modified row are kept in a
RowData, which references a
QueryContext, which references a
DatabaseConnection, which references a
Transaction, which is the Transaction
under which that change was made.
Each field of the row is represented by a
DataCell.
When an application
issues an SQL request
to update the database, it eventually makes it down to
Statement.evaluate,
for example in Insert.
That evaluate method uses its
DatabaseConnection to get a
DataTable for a table name,
which is a wrapper around the
MutableTableDataSource
returned by the DatabaseConnection's
Transaction for the table of that name.
The MutableTableDataSource (created by
Transaction.getTable) is in turn a wrapper around a
MasterTableDataSource
created using the private class
MasterTableDataSource.MMutableTableDataSource.
The Statement uses its
DataTable to create a
RowData, then passes it to its
DataTable, which passes it to the
MutableTableDataSource,
which passes it to the
MasterTableDataSource,
which actually makes the change.
The Transaction maintains a
TransactionJournal, in which
are listed all of the tables which have been changed by the Transaction.
Eventually the
Transaction is closed
(committed or
rolled back),
which is handled by the
TableDataConglomerate
(
processCommit or
processRollback),
which, for each MasterTableDataSource, gets a
MasterTableJournal for it from the
TransactionJournal
specifying what changes have been made in that table
from this Transaction, and tells that
MasterTableDataSource
to commit or roll back the changes in that MasterTableJournal.
Locking
Locking is used to control concurrent access by two requests in the same
Transaction.
This is handled during
query execution
in
JDBCDatabaseInterface.execQuery
Each DatabaseConnection
has associated with it a single
LockingMechanism object,
which is used to
lock and
unlock
the DatabaseConnection's
Transaction as a whole.
The active lock is represented by a
LockHandle, which is returned by
LockingMechanism.lockTables,
and which is passed back to
LockingMechanism.unlockTables to drop the lock.
A lock on an individual table is represented by a Lock,
which is kept in a LockingQueue,
which maintains the link to the locked table.
Update Sequence
When a change is made to the database (insert, update, or delete),
the following list shows the sequence in which various steps are taken:
|
Java Source File Name | Type | Comment |
AbstractAggregateFunction.java | Class | Provides convenience methods for handling aggregate functions (functions
that are evaluated over a grouping set). |
AbstractDataTable.java | Class | This is the abstract class implemented by a DataTable like table. |
AbstractFunction.java | Class | An abstract implementation of Function. |
AbstractInternalTableInfo.java | Class | An implementation of InternalTableInfo that provides a number of methods to
aid in the productions of the InternalTableInfo interface. |
AbstractInternalTableInfo2.java | Class | An implementation of InternalTableInfo that provides a number of methods to
aid in the productions of the InternalTableInfo interface for a transaction
specific model of a set of tables that is based on a single system table. |
AbstractQueryContext.java | Class | |
Assignment.java | Class | An assignment from a variable to an expression. |
BlindSearch.java | Class | This is a scheme that performs a blind search of a given set. |
BlobStore.java | Class | A structure inside an Area that maintains the storage of any number of large
binary objects. |
BlobStoreInterface.java | Interface | A very restricted interface for accessing a blob store. |
Caster.java | Class | Methods to choose and perform casts from database type to Java types. |
CellBufferInputStream.java | Class | This is a reusable cell stream object that is extended from the
ByteArrayInputStream class, which provides methods for reusing the object
on a different byte[] arrays. |
CellBufferOutputStream.java | Class | This is a ByteArrayOutputStream that allows access to the underlying byte
array. |
CellInput.java | Interface | |
CellInputStream.java | Class | An implementation of CellInput that reads data from an underlying stream. |
CollatedBaseSearch.java | Class | An implementation of SelectableScheme that is based on some collated set of
data. |
CompositeTable.java | Class | A composite of two or more datasets used to implement UNION, INTERSECTION,
and DIFFERENCE. |
ConnectionTriggerManager.java | Class | A trigger manager on a DatabaseConnection that maintains a list of all
triggers set in the database, and the types of triggers they are. |
ConvertUtils.java | Class | Various static database convertion tools for converting for upgrading
parts of the database. |
CorrelatedVariable.java | Class | A wrapper for a variable in a sub-query that references a column outside
of the current query. |
Database.java | Class | The representation of a single database in the system. |
DatabaseConnection.java | Class | An object that represents a connection to a Database. |
DatabaseConstants.java | Interface | Contant static values that determine several parameters of the database
operation. |
DatabaseConstraintViolationException.java | Class | A database exception that represents a constraint violation. |
DatabaseDispatcher.java | Class | This is the database system dispatcher thread. |
DatabaseException.java | Class | Exception thrown where various problems occur within the database. |
DatabaseProcedure.java | Interface | This interface represents a database procedure that is executed on the
server side. |
DatabaseQueryContext.java | Class | An implementation of a QueryContext based on a DatabaseConnection object. |
DatabaseSystem.java | Class | This class provides information about shared resources available for the
entire database system running in this VM. |
DataCellCache.java | Class | This object represents a cache for accesses to the the data cells within
a Table. |
DataCellSerialization.java | Class | An object that manages the serialization and deserialization of objects
to the database file system. |
DataIndexDef.java | Class | Represents index meta-information on a table. |
DataIndexSetDef.java | Class | Represents the meta-data for a set of indexes of a table. |
DataTable.java | Class | DataTable is a wrapper for a MutableTableDataSource that fits into the
query hierarchy level. |
DataTableColumnDef.java | Class | All the information regarding a column in a table. |
DataTableDef.java | Class | A definition of a table. |
DataTableFile.java | Interface | This interface handles the abstraction of retreiving information from a
database file. |
DataTableFilter.java | Class | This object sits on top of a DataTable object filtering out certain types
of calls. |
DataTableListener.java | Interface | A DataTableListener is notified of all modifications to the raw entries
of the data table. |
DefaultDataTable.java | Class | This represents a default implementation of a DataTable. |
DumpHelper.java | Class | A helper class for the 'Table.dumpTo' method. |
Expression.java | Class | An expression that can be evaluated in a statement. |
ExpressionPreparer.java | Interface | An interface used to prepare an Expression object. |
FilterTable.java | Class | A table that is a filter for another table. |
FixedRecordList.java | Class | A structure that provides a fast way to read and write fixed sized nodes in
a Store object. |
FixedSizeDataStore.java | Class | A file format that allows for the very quick retreival of data that is
stored within it. |
Function.java | Interface | Represents a function that is part of an expression to be evaluated. |
FunctionDef.java | Class | A definition of a function including its name and parameters. |
FunctionFactory.java | Class | A factory that generates Function objects given a function name and a
set of expression's that represent parameters. |
FunctionInfo.java | Interface | Meta information about a function. |
FunctionLookup.java | Interface | An interface that resolves and generates a Function objects given a
FunctionDef object. |
FunctionTable.java | Class | A table that has a number of columns and as many rows as the refering
table. |
GrantManager.java | Class | A class that manages the grants on a database for a given database
connection and user. |
GroupHelper.java | Class | This is a static class that provides the functionality for seperating a
table into distinct groups. |
GroupResolver.java | Interface | Similar to VariableResolver, this method is used by grouping Functions to
find information about the current group being evaluated (used for
evaluating aggregate functions). |
GTConnectionInfoDataSource.java | Class | An implementation of MutableTableDataSource that presents the current
connection information.
NOTE: This is not designed to be a long kept object. |
GTCurrentConnectionsDataSource.java | Class | An implementation of MutableTableDataSource that presents the current
list of connections on the database.
NOTE: This is not designed to be a long kept object. |
GTDataSource.java | Class | A base class for a dynamically generated data source. |
GTPrivMapDataSource.java | Class | A GTDataSource that maps a Privs 11-bit set to strings that represent the
priv in human understandable string. |
GTProductDataSource.java | Class | An implementation of MutableTableDataSource that models information about
the software.
NOTE: This is not designed to be a long kept object. |
GTSQLTypeInfoDataSource.java | Class | A GTDataSource that models all SQL types that are available.
NOTE: This is not designed to be a long kept object. |
GTStatisticsDataSource.java | Class | An implementation of MutableTableDataSource that presents database
statistical information.
NOTE: This is not designed to be a long kept object. |
GTTableColumnsDataSource.java | Class | An implementation of MutableTableDataSource that presents information
about the columns of all tables in all schema.
NOTE: This is not designed to be a long kept object. |
GTTableInfoDataSource.java | Class | An implementation of MutableTableDataSource that presents information
about the tables in all schema.
NOTE: This is not designed to be a long kept object. |
IndexSet.java | Interface | A set of list of indexes. |
IndexSetStore.java | Class | A class that manages the storage of a set of transactional index lists in a
way that is fast to modify. |
IndexStore.java | Class | A class that manages the storage of a set of transactional index lists in a
way that is fast to modify. |
INHelper.java | Class | This is a static class that provides methods for performing the Query
table command 'in' and 'not in'. |
InsertSearch.java | Class | This is a SelectableScheme similar in some ways to the binary tree. |
InternalFunctionFactory.java | Class | A FunctionFactory for all internal SQL functions (including aggregate,
mathematical, string functions). |
InternalJDBCHelper.java | Class | Helper and convenience methods and classes for creating a JDBC interface
that has direct access to an open transaction of a DatabaseConnection. |
InternalTableInfo.java | Interface | A class that acts as a container for any system tables that are generated
from information inside the database engine. |
JoinedTable.java | Class | A Table that represents the result of one or more other tables joined
together. |
JoiningSet.java | Class | Used in TableSet to describe how we naturally join the tables together.
This is used when the TableSet has evaluated the search condition and it
is required for any straggling tables to be naturally joined. |
Lock.java | Class | This is a lock on a table in the LockingMechanism class. |
LockHandle.java | Class | This represents a handle for a series of locks that a query has over the
tables in a database. |
LockingMechanism.java | Class | This class represents a model for locking the tables in a database during
any sequence of concurrent read/write accesses.
Every table in the database has an 'access_queue' that is generated the
first time the table is accessed. |
LockingQueue.java | Class | This class is used in the 'LockingMechanism' class. |
MasterTableDataSource.java | Class | A master table data source provides facilities for read/writing and
maintaining low level data in a table. |
MasterTableGarbageCollector.java | Class | A row garbage collector for a master table data source that manages
garbage collection over a MasterTableDataSource object. |
MasterTableJournal.java | Class | A journal of changes that occured to a table in a data conglomerate during
a transaction. |
MasterTableListener.java | Interface | An interface that is notified of add/remove events on a
MasterTableDataSource. |
MultiVersionTableIndices.java | Class | This class manages a set of indices for a table over different versions.
The indices include the list of rows (required), and any index data
(optional). |
MutableTableDataSource.java | Interface | A mutable data source that allows for the addition and removal of rows. |
NaturallyJoinedTable.java | Class | A table that is the cartesian product of two tables. |
OpenTransactionList.java | Class | The list of all currently open transactions. |
Operator.java | Class | An operator for an expression. |
OuterTable.java | Class | A Table class for forming OUTER type results. |
ParameterSubstitution.java | Class | An object that represents a constant value that is to be lately binded to
a constant value in an Expression. |
PatternSearch.java | Class | This is a static class that performs the operations to do a pattern search
on a given column of a table. |
Privileges.java | Class | A set of privileges to grant a user for an object. |
ProcedureConnection.java | Interface | An interface for accessing a database connection inside a stored procedure. |
ProcedureException.java | Class | An exception that is generated from a stored procedure when some erronious
condition occurs. |
ProcedureManager.java | Class | A DatabaseConnection procedure manager. |
ProcedureName.java | Class | The name of a procedure as understood by a ProcedureManager. |
QueryContext.java | Interface | Facts about a particular query including the root table sources, user name
of the controlling context, sequence state, etc. |
QueryPlan.java | Class | Various helper methods for constructing a plan tree, and the plan node
implementations themselves. |
QueryPlanNode.java | Interface | A node element of a query plan tree. |
RawDiagnosticTable.java | Interface | An interface that allows for the inspection and repair of the raw data
in a file. |
RawTableInformation.java | Class | This object represents the lowest level DataTable information of a given
VirtualTable. |
ReferenceTable.java | Class | This is an implementation of a Table that references a DataTable as its
parent. |
RegexLibrary.java | Interface | An interface that links with a Regex library. |
RIDList.java | Class | This is an optimization to help sorting over a column in a table. |
RootTable.java | Interface | Interface that is implemented by all Root tables. |
RowData.java | Class | Represents a row of data to be added into a table. |
RowEnumeration.java | Interface | This enumeration allows for access to a tables rows. |
SchemaDef.java | Class | A definition of a schema. |
SelectableRange.java | Class | An object that represents a range of values to select from a list. |
SelectableRangeSet.java | Class | Represents a complex normalized range of a list. |
SelectableScheme.java | Class | Represents a base class for a mechanism to select ranges from a given set.
Such schemes could include BinaryTree, Hashtable or just a blind search.
A given element in the set is specified through a 'row' integer whose
contents can be obtained through the 'table.getCellContents(column, row)'.
Every scheme is given a table and column number that the set refers to.
While a given set element is refered to as a 'row', the integer is really
only a pointer into the set list which can be de-referenced with a call to
table.getCellContents(row). |
SequenceManager.java | Class | An object that manages the creation and removal of sequence keys, and that
offers access to the sequence values (possibly cached). |
SimpleRowEnumeration.java | Class | A RowEnumeration implementation that represents a sequence of rows that
can be referenced in incremental order between 0 and row_count (exclusive). |
SimpleTableQuery.java | Class | A simple convenience interface for querying a MutableTableDataSource
instance. |
SimpleTransaction.java | Class | An simple implementation of Transaction that provides various facilities for
implementing a Transaction object on a number of MasterTableDataSource
tables. |
StatementCache.java | Class | A cache that maintains a serialized set of StatementTree objects that can
be deserialized on demand. |
StatementException.java | Class | An error that is thrown when there is erronious information in a statement. |
StatementTree.java | Class | A serializable container class for a parsed query language statement. |
StatementTreeObject.java | Interface | An complex object that is to be contained within a StatementTree object. |
StateStore.java | Class | A store that manages the current state of all tables in a Conglomerate. |
StoreSystem.java | Interface | An object that creates and manages the Store objects that the database engine
uses to represent itself on an external medium such as a disk, and that
constitute the low level persistent data format.
This interface is an abstraction of the database persistence layer. |
SubsetColumnTable.java | Class | This object is a filter that sits atop a Table object. |
SystemQueryContext.java | Class | A QueryContext that only wraps around a TransactionSystem and does not
provide implementations for the 'getTable', and 'getDatabase' methods. |
Table.java | Class | This is a definition for a table in the database. |
TableAccessState.java | Class | This class provides very limited access to a Table object. |
TableBackedCache.java | Class | A TableBackedCache is a special type of a cache in a DataTableConglomerate
that is backed by a table in the database. |
TableCommitModificationEvent.java | Class | An object that encapsulates all row modification information about a table
when a change to the table is about to be committed. |
TableDataConglomerate.java | Class | A conglomerate of data that represents the contents of all tables in a
complete database. |
TableDataSource.java | Interface | This interface represents the source of data in a table. |
TableDescriptions.java | Class | An object that is a key part of Database. |
TableFunctions.java | Class | A number of functions that are table set functions such as simple select
operations, joins, unions, sub-query operations, etc. |
TableModificationEvent.java | Class | The event information of when a table is modified inside a transaction. |
TableName.java | Class | A name of a table and any associated referencing information. |
TableQueryDef.java | Interface | An interface to an object that describes characteristics of a table based
object in the database. |
TArrayType.java | Class | An implementation of TType for an expression array. |
TBinaryType.java | Class | An implementation of TType for a binary block of data. |
TBooleanType.java | Class | An implementation of TType for a boolean value. |
TDateType.java | Class | An implementation of TType for date objects. |
TemporaryTable.java | Class | This class represents a temporary table that is built from data that is
not related to any underlying DataTable object from the database. |
TJavaObjectType.java | Class | An implementation of TType for a java object of possibly defined type. |
TNullType.java | Class | An implementation of TType that represents a NULL type. |
TNumericType.java | Class | An implementation of TType for a number. |
TObject.java | Class | A TObject is a strongly typed object in a database engine. |
TQueryPlanType.java | Class | An implementation of TType for a query plan value. |
Transaction.java | Class | An open transaction that manages all data access to the
TableDataConglomerate. |
TransactionException.java | Class | Thrown when a transaction error happens. |
TransactionJournal.java | Class | The list of all primitive operations to the database that a transaction
performed. |
TransactionModificationListener.java | Interface | A listener that is notified of table modification events made by a
transaction, both immediately inside a transaction and when a transaction
commits. |
TransactionSystem.java | Class | A class that provides information and global functions for the transaction
layer in the engine. |
TriggerEvent.java | Class | A trigger event represents a high level action that occured in the
database. |
TriggerListener.java | Interface | A listener that can listen for high layer trigger events. |
TriggerManager.java | Class | An object that manages high level trigger events within a Database context.
This manager is designed to manage the map between session and triggers
being listened for. |
TStringType.java | Class | An implementation of TType for a String. |
TType.java | Class | A TType object represents a type in a database engine. |
User.java | Class | Encapsulates the information about a single user logged into the system.
The class provides access to information in the user database.
This object also serves as a storage for session state information. |
UserAccessException.java | Class | An exception that is thrown when the user is not permitted to perform a
certain action. |
UserManager.java | Class | A class that manages the list of users connected to the engine. |
V1FileStoreSystem.java | Class | An implementation of StoreSystem that manages persistant data through the
native file system. |
V1HeapStoreSystem.java | Class | An implementation of StoreSystem that stores all persistent data on the
heap using HeapStore objects. |
V1MasterTableDataSource.java | Class | A MasterTableDataSource that uses IndexStore and VariableSizeDataStore as
its backing mechanism for representing the table structure in a file on
disk. |
V2MasterTableDataSource.java | Class | A MasterTableDataSource that is backed by a non-shared com.mckoi.store.Store
object. |
Variable.java | Class | This represents a column name that may be qualified. |
VariableResolver.java | Interface | An interface to resolve a variable name to a constant object. |
VariableSizeDataStore.java | Class | Provides a mechanism for storing variable length data in a file which can
quickly be indexed via a reference number. |
ViewDef.java | Class | A ViewDef object is a definition of a view stored in the database. |
ViewManager.java | Class | A DatabaseConnection view manager. |
VirtualTable.java | Class | A VirtualTable is a representation of a table whose rows are actually
physically stored in another table. |
WorkerPool.java | Class | Maintains a pool of worker threads that are used to dispatch commands to
a Database sub-system. |
WorkerThread.java | Class | This is a worker thread. |