Sunteți pe pagina 1din 14

Hypersonic SQL

Architecture
Components
Demonstration programs and Tools
JDBC Driver classes
Server classes (only required for Client/Server)
Database Engine
Utilities (not required for Runtime)
How the components interact
The user applications work
with the JDBC interface only Demonstration programs and Tools

There are different use cases:


Standalone mode
JDBC Interface
(application and database
are in the same JVM) HTTP
Connection
Standalone
HSQL
Connection

HTTP connection over the


internet using an own
WebServer or a Servlet
WebServer Servlet Server

TCP/IP connection (intranet)


using a dedicated database Database Engine
Server
DB Engine Overview
Each connection uses a different jdbcConnection / WebServerConnection / ServerConnection /
Servlet
Channel
The Channel has a link to a
Channel Result
User and a list of Transaction
User
objects (a Transaction object is Record (linked list)
a single row insert or delete in a Transaction (Vector)

table)
The Database contains the Database
Tables, the Access rights and
Access Log
the Log file writer
The answer from the database Table (Vector) User
(Vector)
Cache

is a Result object (this may


contains Records, or exception
DatabaseInformation
description or update count)
How a statement is processed
The Database creates a Tokenizer that breaks the statement in words
If it’s a INSERT, UPDATE, DELETE or SELECT, a Parser is created (all
other statements are processed by the Database directly)
The Parser creates a Select object if it’s a SELECT. This Select contains
one or more TableFilter (a conditional cursors over a table),
Expressions and maybe another Select (if it’s a UNION)

Database Parser Select

Access Log
TableFilter (Vector)
Table (Vector) User Tokenizer
Cache
(Vector)
Expression [condition]

Expression (Vector)
DatabaseInformation [columns]

Select [union]
A Table contains
…a Name (not listed) Table
…Column descriptions (with
column name, datatype,…)
Column (Vector)
…one or more Index (the
rows are accessible only
trough an index) Index (Vector)
…a Cache if it’s not an in-
memory table
…maybe Contraints (if there Cache
are foreign keys defined)
If the user didn’t create Primary
key, a hidden column & Index is Constraint (Vector)
created automatically
How the data is saved
The Index is a AVL binary Index
tree (a special binary tree) Node [root]
Each Index contains a root
Node (‘null’ if the table is Node [parent]

empty) Node [left]


Each node may have a
parent node and a left Node [right]

and/or right child


Row [data]
Each node is linked to the
Row (the row contains the Table

data) Object
The data is an array of (array) [data]

Objects
Table with conditions applied
A TableFilter has a link to the TableFilter
underlying table
An Index must be used to Table
scroll through the records
There is a current Node, and
Index [used index]
functions to fetch the first or
next row where the
conditions apply
Node [current]
There may be a starting
condition (Id>100) and an
ending condition (Id<100) Expression
and other conditions [condition: start, end,
(Id<>50) for the index used and]
Simple or complex Expressions
Contains a type (not listed) Expression

Maybe there are operands Expression [arg, arg2]

(arguments)
Object [data]
A simple Expression can be
just a value (an Object) Hashtable [valuelist]
Or a list of values (1,2,3,4)
Select [subquery]
Or a subquery (nested
SELECT) Function

Or a Function (with Expression


(Vector) [arg]
arguments)
Or a column in a filtered TableFilter
Table
The transaction Log system
In the In-Memory database there is no disk access
In the Standalone mode the SQL commands are appended to
the .script file after they are executed
The .properties file contains the current state of the database
The .script file is re-created (and so shrinks) when the database
is closed or when a CHECKPOINT occurs

Log .properties:

modified=no
.script: version=1.3
readonly=false
CREATE TABLE ...
INSERT INTO ...
INSERT INTO ...
INSERT INTO ...
How records are cached
The Cache is a Cache
hashtable
Row
Additionally, the records Data
(array)
in the cache are linked
together in a double
linked list
If there are too many
records in the cache,
the oldest records are
saved (if required) and .data:

removed from the cache [contains the binary records and empty blocks]
File system overview
Log .properties:

modified=no
.script: version=1.3
readonly=false
CREATE TABLE ...
INSERT INTO ...
INSERT INTO ...
INSERT INTO ...

.backup:

.data: [contains a
Cache compressed backup of
[contains the binary old .data file]
Row records and empty
Data blocks]
(array)
Transaction handling
The Channel keeps track of Channel

the uncommited transactions User

Each Transaction objects Transaction (Vector)


contains a reference to the
‘old’ data
Statements that may fail (for [current]

example UPDATEs) starts a


nested transaction, but more
nesting is not built in
Rollback is done by un-doing [nested]
(re-inserting or deleting) the
changes in reverse order
Database Metadata and Script
Systemtables are built jdbcDatabaseMetaData
dynamically (just when they
are required, and in- Database
memory) by the Table (Vector) Access Log
DatabaseInformation class
Dynamic DatabaseMetaData DatabaseInformation

functions calls returns data MetaData

from this systemtables SYSTEM_TABLES


SYSTEM_COLUMNS
SYSTEM_CONNECTIONINFO SYSTEM_TYPEINFO
SYSTEM_INDEXINFO
returns data about the ...
SYSTEM_CONNECTIONINFO
current connection
Additionally a database SQL Script generator

script generator is built in SYSTEM_SCRIPT

S-ar putea să vă placă și