Aldat Lab,School of Computer Science,McGill University, Montreal
Table of
contents:
3.1 Backus-Naur Form for the Parser
3.3.1 Install JavaCC on linux/unix:
3.3.2 Regenerate Parser files:
5.3 Relationship among classes
This developer guide is summarized from Professor Tim Merret’s papers and all Aldat lab students M.Sc. theses and projects. It is a guide for coming students as well as for jRelix system maintenance.
The relational model for representing data was proposed by Codd [Cod70] in early seventies. The relational model, unlike other data models, has a rigorous mathematical definition. However, it has since then been recognized for its simplicity, uniformity, data independence, integrity and evolvability [Ger75].
At McGill, we established generalizations to the relational algebra and created the domain algebra, in order to provide a better basis for a programming language. These extensions also led to a better query language. We studied information system requirements and concluded that the extended algebra is sufficient for all the applications we had envisaged. We called this work the Aldat Project, standing for the algebraic approach to data. [MerWeb]
JRelix, a relational database programming language in Unix, was developed based DBMS at the Aldat lab of School of Computer Science, McGill. JRelix system was classified into three parts: relation algebra, domain algebra and computation [Yua98]. It’s an interpreted language written in Java language. In the relational model, information is represented in table format. Each row is called a tuple and the label of a column is called attribute. A set of values in a column is called a domain. JRelix is based on an algebraic data manipulation language proposed by Merrett [Mer77]. JRelix mainly deals with two kinds of data: relations and domains and two kinds of operations: relational algebra and domain algebra.
JRelix supports relational algebra operations:
JRelix supports domain algebra operations:
In jRelix, there are two kinds of attributes, “actual attributes” and “virtual attributes”. Attributes created by declaring primitive data type and ADT (Abstract Data Type) are called “actual attributes”. Attributes created by expressing the attributes as domain algebra operations on existing attributes are called “virtual attributes”. “Virtual attributes” means no actual values associated with them. The value of virtual attributes is actualized in a jRelix statement.
The most important is that jRelix system is a nested relation model. The nested relational model allows abstract data types to be defined for domains, and allows operations to be defined on them.
The jRelix system is a database system composed of three conceptual modules: a front-end processor, a database engine and a database manager.
Java Compiler Compiler (JavaCC) is an important generator tool in jRelix system. JavaCC is a parser generator. It provides a Java language extension for specifying a programming language’s grammar. It is used to specify the grammar of input stream.
The jRelix parser is created by using JavaCC with a Backus-Naur form. The jRelix parser reads the command-line input. Then, it analyzes the command syntax. If it is wrong, a message is displayed. If it is correct, it translates the command in order to build a syntax tree.
The convention of the BNF definition is shown as followed,
Meaning |
|
<SYMBOL> “SYMBOL” S1 | S2 (SYMBOL)? (SYMBOL)* (SYMBOLS) |
There are five token definitions:
This JavaCC tutorial is from web site: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-cooltools.html , by Oliver Enseling. The appendix shows the free document downloaded from the website.
1. unzip JCC.zip
2. locate the file JavaCC0_6_1.class inside JCC and run this class to install
3. set path appropriately
There are six steps to regenerate parser file after modification:
1. make sure you have these two java source files:Node.java and SimpleNode.java
2. enter command: jjtree Parser.jjt
3. enter command: javacc Parser.jj
4. enter command: jjdoc Parser.jj >
Parser.html
5. remove ParseError.java
6. copy all *.java files into your the directory which contains all other java files for jRelix
JRelix storage
format is the file on the hard disk. The information of all relations and
domains in jRelix system is split into several system files: .rel, .dom, .rd,
.expr, .comp and .surrogate. JRelix maintains three basic system tables on
disk: domain table (.dom), relation table (.rel) and Relation-Domain table
(.rd).
The relation table information is stored permanently in a disk file named “.rel”. The storage fomat is:
Item |
Type |
Description |
name |
string |
relation name |
rvc |
integer |
type(RELATION,VIEW or COMPUTATION) |
numtuples |
integer |
the number of tuples in this relation |
numattrs |
integer |
the number of attributes in this relation |
numsortattrs |
integer |
the number of sorted attributes |
Information on all relations in the database is also maintained by a hash-table in memory, with relation names as hash keys. The structure format is:
Item |
Type |
Description |
name |
string |
relation name |
rvc |
integer |
type(RELATION,VIEW or COMPUTATION) |
numtuples |
integer |
the number of tuples in this relation |
numattrs |
integer |
the number of attributes in this relation |
numsortattrs |
integer |
the number of sorted attributes |
tree |
SimplyNode |
syntax tree root if it is a view |
domain |
Domain[] |
Array of domain objects |
data |
Object[] |
pointer to relation data |
capacity |
int |
capacity of the array of column |
As you can see from the above structure format tables, the items in file .rel are part of the items in memory.
The domain table information is stored permanently in a disk file named “.dom”. The storage fomat is:
Item |
Type |
Description |
name |
string |
domain name |
type |
integer |
domain type |
numref |
integer |
the number of relations that reference this domain |
Type in domain is BOOLEAN, SHORT, INTEGER, LONG, FLOAT, DOUBLE, STRING, TEXT, STMT, EXPR, IDLIST or COMP.
Information on all domains in the database is also maintained by a hash-table in memory, with domain names as hash keys. The structure format is:
Item |
Type |
Description |
name |
string |
domain name |
type |
integer |
domain type |
tree |
SimpleNode |
the syntax tree if it’s a virtual domain, otherwise null |
numref |
integer |
the number of relations that reference this domain |
As you can see from the above structure format tables, the items in file .dom are part of the items in memory.
Information about all expression syntax trees is stored in disk file “.expr”. When jRelix system is running, a temporary hash-table is used by ExprTable calss to store expression trees.
There are many java classes in jRelix system. This part will analyze them in detailed.
In jRelix system, there are three parts: a front-end processor, a database engine and a database manager. ( See Section 2: System Architecture)
Files with “*” are machine generated; developer cannot modify them directly.
Gedit** means all the classes named begin with “Gedit”.
Name Description
1. ExprEntry Entry for .expr System File
This part is for distribute database in jRelix.
Name Description
1. aldatpClient Client side
In jRelix, a virtual attribute is actualized with a tuple-by-tuple approach. The actualized class handles the actualization of virtual attributes. First, the class constructor involves a series of validity checks such as type and loop-declaration. Then, after the validity checks are passed, all virtual attributes will be actualized. There are some important methods: Actualizer(),buildTree() and actualize() (starred in the following list).
5.2.3 BlockInputStream class
5.2.4 BlockOutputStream class
This class is used to implement the block access the data on disk. The instances of this class are constructed with two arguments: disk file name and buffer size.
5.2.5 CompBlock class
This is a class to support “Computation class” for storing information about an "alt" block in a convenient way.
class CompBlock implements Constants,
TypeConstants {
//Debugging:
private boolean DEBUG=false;
public int blockType;
//Type of the block
public SimpleNode[] statements; //Statements contained in the block
public int numStatements;
//Number of statements in this block
public SimpleNode blockTree;
//pointer to jjTree for this block
//addition by Yi Zheng July 8, 2002
public boolean redop = false;
//true if can be used as associative commutative operator
public boolean funop = false; // true if can be used as ordered operator
//end of addition by Yi Zheng July 8, 2002
private final int INPUT = 0;
private final int OUTPUT = 1;
public CompBlock(SimpleNode block, Environment env, SimpleNode
tree) throws InterpretError,
SemanticCheckError { }
public void dump(int blocknumber)
{ }
public void dump() { }
private
void findBlockType(SimpleNode stmt, Environment env) throws InterpretError { } //implements block algorithm on one
stmt of the comp
private void updateStatus(int newStat, SimpleNode node, Environment
env) throws InterpretError { }
}
5.2.6 CompTable class
This class CompTable is used to store computation objects that are in a column of some relation. A surrogate is used to identify the individual computations.
public class CompTable {
private Hashtable table;
public CompTable() { }
public void addEntry(long surrogate, Computation comp){} //Add an entry
to the table.
public void addEntry(String name, Computation comp) { } //Add an entry
to the table.
public void addEntry(String fullName, Long surrogate) { } //Add an entry
to the table.
public void fillExprTable(Hashtable exprTable) {} // Fill the exprtable
(a hashtable) before dumping the expressions
public Computation lookup(long surrogate){}
public long lookup(String fullName) {}// look up the surrogate value of
a computation by its full name
public Hashtable getCompTable() { }
}
5.2.7 Computation class
This class implements computation. There are sevral methods are explained as following:
* The constructor handles a computation declaration.
* Method applyIjoin() handles the application of the computation with a relation.
* Method applySelect() handles the application of the computation with a select statement.
* -- applySelect(Relation rel,int currow ...) is overloaded for implementing accessor methods of ADT
* Method applyInOut() handles a stand-alone computation call
* -- applyInOut(Relation rel, ...) is overloaded for implementing modifier methods of ADT
* Method duplicate() returns a duplicate of this Computation
* Method print() is overloaded for the pr command on computation
* Method sc() is for the sc command
(Starred the above methods in the following list)
class Computation extends Relation implements
Constants,TypeConstants {
private boolean DEBUG=false;
public Environment stateEnv; //stateEnv
stores all state vars in a user session for this computation
public boolean isIjoin;//distinguish between Ijoin and Select invocation
public String parentName = new String("");//record the
environment in which this comp is defined
public boolean TOP_LEVEL_INOUT=false;//to distinguish between top level
invocation by in/out syntax
public boolean UPDATE = false;//to distinguish between calls made from
within UPDATE
public CompBlock[] blocks; //
The "alt" blocks of the computation
private Environment declEnv; //
Pointer to parent environment
private Domain[] joinAttrs;
//The input attributes
private Domain[] extraAttrs; //attrs that aren't part of calculation
public static Interpreter interpreter;
* public Computation(SimpleNode node, Environment declEnv) throws InterpretError
*
public void print(int[] lens, boolean flag){}
*
public void sc(){}
*
public Relation applyIjoin(Relation rel, Domain[] domsc, Domain[] domsr,
String filename, Environment callEnv)
throws InterpretError { }
*
public void applyInOut(SimpleNode node, String filename, Environment
callEnv)throws InterpretError {}
*
public Relation applySelect(SimpleNode select, String
filename,Environment callEnv) throws
InterpretError {}
*
public Relation applyInOut(Relation rel, SimpleNode node, Environment
callEnv) throws InterpretError {} //nested
*
public Relation applySelect(Relation rel, int currow, SimpleNode select,
String filename, Environment callEnv)
throws InterpretError {}
*
public Computation duplicate()
throws InterpretError { }
private void reGenerateBlocks(SimpleNode tempTree) throws InterpretError {} //generate domains and blocks for this
computation
private
boolean isReplaceable(IDInfo id) throws InterpretError{ }
private void transformStmt(SimpleNode stmt, Environment env) throws
InterpretError { }
private void transformExpr(SimpleNode
node, Environment env) throws InterpretError {}
private void
runSingleStmtInUpdate(Relation rel, SimpleNode stmt, Environment tempEnv,
NREnvironment NRe) throws InterpretError {}
private boolean constraintMode(Domain[]
joinAttrs, Environment env) { } // Check if this computation is being run in
constraint mode
private Domain[] extraDomains(Domain[] doma,
Domain[] domb) {} // Return the domain
array whose elements are those which are in domb but not in doma.
private Domain[] extraDomains2(Domain[] doma, Domain[] domb, Hashtable
tbl) {}
private CompBlock findBlock(Domain[]
joinAttrs, Environment env) throws
InterpretError {} // Decide which "alt" block to use this time
around.
private void initializeData(Relation rel, Environment env, Domain[]
tempJoinAttrs) {} // Initialize the data array
private
Environment initializeEnvironment(SimpleNode node, Environment env, Environment callEnv) throws InterpretError {}
private Relation makeRelation(String name, Environment env) throws InterpretError {} //Make this
computation into a relation on the current 'data'
private Domain[] replaceJoinAttrs(Domain[] doms, Hashtable tbl) throws
InterpretError {} // replace join attributes
private void parseSelectConditional(SimpleNode node, Vector inputDoms,
Environment env, Environment callEnv) throws
InterpretError {} // parses the conditional expression in the selector
private int processCallParams(SimpleNode callParams, String prefix, Environment env, Environment callEnv)
throws InterpretError {} // put input call parameters into LocalInfo objects
private void renameIDs(SimpleNode node, String prefix, Environment
env) throws InterpretError {} // It renames the identifiers in the
syntax tree
private void run(CompBlock block, Environment env) throws InterpretError {}
private void renameParamsInTree(SimpleNode tree, Hashtable tbl) {}
private void renameParamInTree(SimpleNode tree, String oldName, String
newName) { } // rename a single
parameter
private void runConstraint(CompBlock block, Environment env, Vector
failRows) throws InterpretError {} // run constraint mode
private Relation makeRelationConstraint(String name, Environment env,
Vector failRows) throws InterpretError {} // update env.data to delete rows
that failed constraint testing and make a relation of the final result
private void runSingleStmtConstraint(SimpleNode stmt, Environment env,
Vector failRows) throws InterpretError
{} //simplest cases are implemented
private void runSingleStmt(SimpleNode stmt, Environment env) throws InterpretError {} //method called by run
private Domain[] getHiddenDoms(Relation rel) {} //get the states in rel
}
5.2.8 Constants class
This abstract class is about all static constants in jRelix system.
5.2.9 CTrigger class
This class is about trigger determination.
class CTrigger {
Relation
oldp; // the parts of relation will
be updated
Relation
newp; // the updated parts of relation
Relation
restp; // the parts of relation won't
be updated
String relname; //
the name of relation to be updated
CTrigger(Environment
env) { } //constructor
}
CTrigger(String
rlname) { } // constructor
}
5.2.10 Domain class
This class encapsulats a single entry in .dom system table. These entries are described in the documentation for the DomTable class.
public class Domain implements TypeConstants,
Constants
{
public String name; //name of
this domain
public int type; //type of
this domain
public int numref; //a
reference count of the number of relations defined on this domain,
public SimpleNode tree;//sytax tree if the
domain is virtual, else null
public int isStateDom = 0;//1 if this domain is declared as a state var
of a computation
public int isRedTemp = 0; //1 if this is a temporary representing a
reduction used for level lifting public
int
public int isRedTempTop = 0; //1 if this is a temporary domain as in the
following case: A <- [red ujoin of U] in R;
public Domain () {} //
constructor
public Domain(String name, int type, Domain[] domlist, Environment
env) throws InterpretError {}
//constructor
public Domain(String nm, int tp, int ref, SimpleNode nd) {}
//constructor
public Domain duplicate(Environment env) throws InterpretError {}
public
SimpleNode getTree() {} // Get the syntax tree for virtual domain.
}
5.2.11 DomTable class
This class stores and accesses .dom system relation in memory. Some information from the .rd system table is kept in class DomTable as well. This class also is the information describing what attributes each domain is defined on and for nested relations. The .dom system relation is as follows: .dom (.name .type .numref) where .name is for the domain, .type is the type of the domain: intg, strg, bool, or rel. and .numref is number of reference .
public class DomTable implements
TypeConstants, Constants{
private boolean DEBUG=false;
private static final int BUF_SIZE = 16 * 1024;
private static final String DOM_NAME = ".dom";
private static final String RD_NAME = ".rd";
private Hashtable table; //storing all the domains.
private RelTable reltable;
private Environment env;
public DomTable(Environment env, boolean
load) {} //Initialize the hash table,
and load domain information from disk files .dom & .rd.
public void addDom(Domain d) {} // Add a domain object to this domtable.
public void dump(){ }Dump this domain table to .dom and .rd
public void fillExprTable(Hashtable exprTable) {} // Fill the exprtable
(a hashtable)
public
Domain getDom(String name){}
public Vector getDoms(String domname){} Get the attributes that a domain
is defined on
public int getType(String name) throws InterpretError{} //the type of a
domain.
public Enumeration keys()
private void load(){} //Load domain information from disk files(.dom).
public boolean rmDom(String name){} // Delete a domain from the DomTable
public void showDom(Domain doment) {} //Print the information for one
domain.
public void showTable(boolean flag){} // Print the domain table.
public int getDomTableSize() // provide the size of the domTable
}
5.2.12 Environment class
This class implements a frame of an environment. It consists of entries of five different "kinds": PARAM, LOCAL, STATE, REL and DOM. These are subclasses of IDInfo which provide convenient storage for each of these, respectively.
class Environment implements Constants, TypeConstants {
private boolean DEBUG=false;
private Environment parent; //Pointer to parent environment
private NREnvironment NRenv; //For use with domain algebra
private Hashtable table; //Table
holding information about params, locals and states
public RelTable reltable; //For holding local domains and relations
public DomTable domtable;
public Object[] data; //used in computation
public int row;//used in computation
public boolean constraint_mode = false;//added by Yi Zheng March 31,
2002
public TriggerNode triggerroot;
public Environment() {}
public Environment(Environment parentEnv)
{}
public Environment(RelTable prel, DomTable
pdom) {}
public Environment(Environment parent,
Hashtable tbl, RelTable prel, DomTable pdom) {}
public void setParent(Environment pEnv) {}
public Environment getParent() {}
public NREnvironment addNRFrame(Relation r) {}
public void clear() {}
public void dump(boolean dumpParent)
throws InterpretError {}
public String[] getStateNamesLocal() {} //NEEDED BY COMPUTATIONS
public IDInfo lookup(String name, boolean searchParent) {}
public Domain lookupDom(String name, boolean searchParent) {}
public ParamInfo lookupParam(String name) {}
public NRInfo lookupNR(String name, boolean searchParent) {}
public
ParamInfo lookupParam(String name, boolean searchParent) {}
public Relation lookupRel(String name, boolean searchParent) throws InterpretError {}
public Relation lookupNestedRel(String name, boolean searchParent) throws InterpretError {}
public Relation lookupNestedRel(String name,
boolean searchParent, int rrow) throws
InterpretError {}
public Relation lookupRelSurr(String name, boolean searchParent) throws InterpretError {}
public long getSurrogate(String name)
throws InterpretError {}
public void setSurrogate(String name, long sur) throws InterpretError {}
public void purge() {}
public void put(Domain d) {}
public void put(String name, IDInfo id) {}
public void put(String name, IDInfo id, boolean searchParent) {} //method used to export inner computations
to parent environment(s)
public void put(Relation r)
throws InterpretError {}
public void put2(Relation r, Environment envFound) throws InterpretError { } //put the
relation in the designated environment
public void removeNRFrame() {}
public void removeRel(String name, boolean searchParent) {}
public void removeDom(String name, boolean searchParent) {}
public void removeParam(String name) {}
public Environment removeRel2(String name, boolean searchParent) {}
public String opcodeToString(int opcode) throws InterpretError {}// convert opcode to string to
represent the prefix/action name in event handle
public int stringToOpcode(String str)
throws InterpretError {} // convert string that represents the
prefix/action name in event handle to opcode
public String getEventName(SimpleNode node) throws InterpretError {
} //to get an actual event name from a tree.
}
5.2.13 EvalExpr class
This class contains evaluators for expressions that should return one of the follwoing types:Boolean short, integer, long, float, double and string.
class EvalExpr implements Constants,
TypeConstants {
private static boolean DEBUG = false;
public static boolean WEIZHONG = false;
public static Interpreter interpreter; //In order to use
evaluateTLExpression() in Interpreter class
static Hashtable emptyht = new Hashtable(); //Empty hashtable needed as hack since evaluateTLExpression()
public
static boolean evalBooleanExpr(SimpleNode node, Environment env) throws InterpretError {}
public static double evalDoubleExpr(SimpleNode node, Environment
env) throws InterpretError {}
public static float evalFloatExpr(SimpleNode node, Environment env) throws InterpretError {}
public static int evalIntExpr(SimpleNode node, Environment env) throws InterpretError {} //the fix is to
enhance StateInfo object with value holders
public static int evalIntExpr_old(SimpleNode node, Environment env) throws InterpretError {}
public static number evalNumExpr(SimpleNode node, Environment env) throws InterpretError {}
public static long evalLongExpr(SimpleNode node, Environment env) throws InterpretError {}
public static short evalShortExpr(SimpleNode node, Environment env) throws InterpretError {}
public static String evalStringExpr(SimpleNode node, Environment
env) throws InterpretError {}
public static Object evalObjectExpr(SimpleNode node, Environment
env) throws InterpretError {}// for in
If case
}
5.2.14 ExprTable class
public class ExprTable implements Constants,
TypeConstants {
private static final String EXPR_FILE_NAME = ".expr";
private Environment env;
private RelTable reltable;
private DomTable domtable;
private CompTable comptable;
private Hashtable exprtable; // expression table.
public ExprTable(Environment env, CompTable
comp) throws InterpretError {}
public void dump() {} // Dump the expression information to disk
file .expr.
public void load() {} throws InterpretError {}
// Load the expression information from .expr and .view.
public void showTable(){} //
Print table information.
public void showTable2(){
}//Orignial version: Print table information.
public Hashtable getExprtable() { }
}
5.2.15 Global class
This class contains global attributes/methods for sharing.
class Global
implements TypeConstants, Constants{
private
static boolean DEBUG=false;
public static Environment environment;
//global Environment
public static CompTable comptable; // global
Tables
public static ExprTable exprtable;
public static JRelixInputStream jin;
// the JRelixInputStream for the parser
public static int status; // the
status of the current parser
public static SimpleNode root;
// the root of the current JJTREE
public static long interpretTime;
// the interpret time of the current JJTREE
public static Stack aldatp_list;
// the aldatp servers invoked by this JRelix run
public static int start_type; //0:stand-alone 1:server.
public static Stack
availablePort ;// top level server stores the available reserved port number
for the sub server.
public static Hashtable services
;// top level server 's dictionary: sub server's path and it's port number.
public static int active_threads = 0; //the number of active threads
public static boolean permit_start = true ; //true: allow new threads be
forked
public static Hashtable
DataFileSet = new Hashtable(); //store the removed relation files' mode
public static Hashtable
userHomes = new Hashtable(); //store user names and home directorys
public static boolean debug = false;
//debug toggle, true for ON
public
static boolean batch = false; //batch
toggle, true for ON
public static boolean expert = false;
//expert toggle, true for ON
public static boolean time = false;
//time toggle, true for ON
public static boolean trace = false;
//trace toggle, true for ON
public static boolean ssd = false;
public static boolean ssr = false;
public static final InputStream instream = System.in;
public static final PrintStream outstream = System.out;
public
static PrintStream traceoutstream = null;
private static final String RD_NAME = ".rd";
private static final int BUF_SIZE = 16 * 1024;
static { }
public static void beforeInterpret() {}// implements the action needed
before the Interpret
public
static void afterInterpret() { }// implements the action needed after the
parsed node is interpreted.
public static void afterSRDInterpret() { } // implements the action
needed after the parsed node is interpreted.
public static void beforeParse() {} // implements the action needed
before the user input is parsed.
public static void afterParse(Environment env) {} throws InterpretError
// implements the action after the user input
public static void traverse(SimpleNode node) {}
public static void cleanup(SimpleNode node) { }
public static void switchNode(SimpleNode node) {}// implement
using...change as alternative to change...using in updates
public static void filterFile
(String source, String target)
public static void exit(int status) {} // for distribute database to
exit connection
public static void quit(int status) { } //quit from jRelix
public static void save() {} //save all information into disk
private static void fillDomArray(Domain[] doms,String domname, int
index, Environment env)throws InterpretError {}
public static void flush() {}
private static void init() throws InterpretError //added by Yi Zheng
March 18, 2002
private static void loadRDTable(Environment env) throws InterpretError{}
// load the Relation/Domain (RD) tables from the files on disk
private static void populateInitData(String relName, Environment env)
throws InterpretError {} // populates .rel, .dom, .rd system relations at
startup and stores them on to disk
public static void print(String name) {}//This method print a String.
public static void println(String name) {} println a String
public static void print(Throwable e) {} // print a Throwable
public static void println(Throwable e) { }// println a Throwable
public
static void printHead () { } //print the jRelix head.
public static void processThrowable(Throwable e) {}
public static void processThrowable(Throwable e, PrintStream out) {}
public static int saveCompCode(Environment env) throws InterpretError {}
// Save the user input text for the computation declaration if it is.
public static void tracePrint(String name) {} // print a String to the
OutputStream for the trace.
public static void tracePrintln(String name) {} // println a String to the
OutputStream for the trace.
}
5.2.16 IDInfo class
This abstract class is a structure that stores information about all the parameters and variables in a computation. This includes for each variable:
*what is its kind? (PARAM, LOCAL, STATE..)
* is it a local variable?
* if so, what is its current value?
*which column is the (local?)/state var or parameter in?
public abstract class IDInfo implements
TypeConstants {
public int kind = RELIX_VOID;
public int inoutStatus = RELIX_VOID; //used only by the block type
algorithm when a computation is declared.
public int type = RELIX_VOID;
public IDInfo() {}
abstract void dump();
}
5.2.17 Interpreter class
This class receives a syntax tree from parser class and dispatch function calls into the database. A single Interpreter object is instantiated and used throughout a user session of jRelix system. Several jRelix command functions such as help, quit, pr and etc are implemented in this class. It also provides methods that perform basic validity check.
public class Interpreter implements
Constants, TypeConstants{
private boolean DEBUG=false;
private boolean DEBUG_09_22_2002 = false;
public Environment env; // the
top level environment
private
CompTable comptable; // Relation system table
private ExprTable exprtable; //
Expression system table
private Parser parser; //
the parser
private Stack instack;
//stack for old input streams
private InputStream in;
//current parser input stream
public static final String temp_name_prefix = "_temp_X9X_";
private static final int MAX_TEMP_FILE = Integer.MAX_VALUE;
private static int next_number = 0;
private static final int MAX_INITIALIZE_SIZE = 10000;
public Relation destrel = null;
public int currow = -1;
public Interpreter () { }
private void assignLiteral(Relation rel, int i, int offset, SimpleNode
node) throws InterpretError{}
private Vector CreateDAG(String relname, Environment env) throws
InterpretError {}
private void CreateData(Hashtable ht, String
name, Environment env) throws InterpretError{}
// create data array for a relation and put the relaton into the
hashtable
private Hashtable CreateDataHashTable(String name, Environment env) throws InterpretError {} // Create all
relations and their data arrays and use hashtable to store all relations
public static void deleteFile(String filename) {}// delete a data file on disk
private boolean equals(Relation rl, Relation rr) throws InterpretError {}
private Relation evaluateJoin(SimpleNode node, String filename,
Hashtable htable, Environment env) throws InterpretError {}//evaluating the
join specified in the node's tree.
private Relation evaluateGedit(SimpleNode node,String filename,
Hashtable htable, boolean flag, Environment env, Domain[] doms) throws
InterpretError {}
private Relation evaluateProject(SimpleNode node, String filename, Hashtable htable, boolean flag, Environment
env) throws InterpretError{}
private Relation evaluateQSelect(SimpleNode orgNode, String
filename, Hashtable htable,
Environment env) throws
InterpretError {}
private Vector qtEvaluateProj(SimpleNode node,Environment env, Vector
allDoms) throws InterpretError{}
private Vector qtEvaluateQuantDom(SimpleNode node,Environment env,Vector
allDoms) throws InterpretError {}
private Domain[] qtEvaluatePred(SimpleNode node,Environment env) throws InterpretError {}
private Vector qtEvaluateDomInQuant(SimpleNode node, Environment env,Vector
alldoms) throws InterpretError {}
private Relation evaluateSelect(SimpleNode node, String filename,
Hashtable htable, Environment env) throws InterpretError {} // Returns relation only with tuples selected by
the selector as specified by the tree of node.
public Relation evaluateTLExpression(SimpleNode node, String filename,
Hashtable htable, Environment env)
throws InterpretError{} // evaluate Top Level expression, which results
in a relation
private Relation evaluateView(SimpleNode node, String filename,Hashtable
htable, Environment env) throws
InterpretError {} // evaluate top level view and return the result relation
private void executeAssignment(SimpleNode node, Environment env) throws InterpretError {}
public void executeCompCommand(SimpleNode node, Environment env) throws InterpretError {}
private void executeCommand(SimpleNode node, Environment env) throws InterpretError {}
private String getEveAtt(SimpleNode node, Environment env) throws InterpretError {}
private
void executeCommand(SimpleNode node, Environment env, String rlname, int opc)
throws InterpretError {} // overload the function to handle the different
level's undo command in event handlers
private int printTrigger(CTrigger trigger) throws InterpretError {}
private int printAllTrigger(TriggerNode triggernode) throws InterpretError {}
public void executeCompDeclaration(SimpleNode node, Environment env)
throws InterpretError {}
private void executeDeclaration(SimpleNode node, Environment env) throws
InterpretError {}
private void AddVirtDom2DomTable(SimpleNode node, Environment env) throws InterpretError
{} // Original code for processing
Virtual Domain declaration
public void executeCompStatement(SimpleNode node, Environment env)
throws InterpretError {}
private void executeStatement(SimpleNode node, Environment env) throws
InterpretError {}
private int getIDCol(Relation r) throws InterpretError {} // to get the
'.id' col position involved in assignment operation
public static int CompareRelType(Relation left, Relation right) throws InterpretError {} // compare the
types of the two relations
public static int CompareRelTypeComp(Relation left, Relation right) throws InterpretError {} // used for
comparison between two relations
public
int lookCompUpdate(SimpleNode node, Environment env, Relation prtmp,
TriggerNode triggernode) throws InterpretError {}
private int lookUpdate(SimpleNode node, Environment env, Relation prtmp,
TriggerNode triggernode) throws InterpretError {} // to produce the three parts relation of trigger for the
certain update
public int executeCompUpdate(SimpleNode root, SimpleNode node,
Environment env) throws InterpretError
{}
private int executeUpdate(SimpleNode root, SimpleNode node, Environment
env) throws InterpretError {}
public void doCompTrigger(Environment env, TriggerNode triggernode, int
searchchild) throws InterpretError {}
private void doTrigger(Environment env, TriggerNode triggernode, int
searchchild) throws InterpretError {} // use the env.trigger to produce the new
updated relation
private Domain[] ExpressionListToGeditDomains(SimpleNode node,Domain[]
doms,int projectno) throws InterpretError {}
private Domain[] ExpressionListToDomains(SimpleNode node) throws
InterpretError {} // convert an ExpressionList node to an array of domains
public Domain[] AttribsRel2DomList(Relation rel) throws InterpretError
{}
private Domain[] ExpressionListToDomains(SimpleNode node, Relation rel, Hashtable
htable, Environment env) throws InterpretError {}
private Domain[] ExpressionListToDomains(Domain[] node, Relation rel)
throws InterpretError {} // adds hidden state domains from rel to the domains
private Domain[] ExpressionListToDomains(SimpleNode node, Relation rel)
throws InterpretError {}
public Domain[] ExpressionListToDomains(SimpleNode node, Hashtable
htable, Environment env) throws
InterpretError {}
private Domain[] handleRedDomain(Domain[] domArray, SimpleNode node,
Relation rel, Environment env) throws InterpretError {} // generate a temporary
domain for red node that is intended for level lifting
private void getDomsInCompList(SimpleNode node, Hashtable htable,
Environment env) throws InterpretError {}
private Relation getIDList(SimpleNode node, Environment env) throws
InterpretError {} // Return a virtual relation
private Relation getProjListRel(Relation rel, SimpleNode arrayList,
Environment env) throws
InterpretError {} // returns a relation containing the domains to appear in the
projection list
private void help(String name)
throws InterpretError {} //
convert an IDList node to an array of domains
private Domain[] IDListToDomains(SimpleNode node, Environment env) throws InterpretError {}
public long interpret(SimpleNode node,
Environment env) throws InterpretError {}
public long interpret(SimpleNode node, Environment env, String rlname,
int opc) throws InterpretError {} //
overload the original interpret to handle the UNDO command
private void lefthandUpdate(SimpleNode node, Environment env) throws
InterpretError {}
private void reverseView(SimpleNode node, Environment env) throws
InterpretError {}
public void distributedStmt(String rname,String lname,String URL, int
op,Environment env) throws InterpretError {}
private boolean isRecursiveView(SimpleNode node, String name, Hashtable htable, Environment env) throws
InterpretError {} // check if there is
self-reference in a view expression, the semantic
public void traverse(SimpleNode node) {} // traverse and output the dump
info to screen
public void mainLoop(String args[]) { } // The main loop for the
interpretation.
public Domain newVirDomain(String name, SimpleNode node, Environment
env) throws InterpretError {} // used for virtual domains.
public static String nextTempName() // Return the a temporary file name
for intermediate result in relational operation
private void parse(String sp) {}
private void RelationalDeclaration(SimpleNode node, Environment env)
throws InterpretError {} // handle parsing of a relational declaration with
optional initialization
private long RelationalInitialization(SimpleNode node, Hashtable
relsHT,String name, long surr, int
tupleNum) throws InterpretError {}
// recursive routine to initialize a
relation using the curly bracket syntax
private void traverseNode(SimpleNode node, int flag, Environment env)
throws InterpretError {} // Traverse the syntax tree of a virtual domain.
private int traverseType(SimpleNode node, Environment env) throws InterpretError {} // Get the
actualized type
private int executeEventH(String prefixname, SimpleNode enode,
Environment env) throws InterpretError {}
public boolean executeEventH( String actionname, Environment env) throws InterpretError {}
public boolean IsEmbody(String handAtt, String queAtt) {}
public void RemoveTrigger(TriggerNode triggernode) {} // to clear up
trigger
public void printNode(SimpleNode Node) {}
public
int executeRelixCommand(String commd){}
public void
executeJRelixCommand(String commd) {}
public Relation getRelbyName(String name) throws InterpretError {}
}
5.2.18 InterpretError class
This exception is thrown by method DBInterpreter.
5.2.19 JRelix class
This class is the entry of jRelix system. It contains “main”.
5.2.20 JrelixInputStream class
This class is to input in jRelix system.
class JRelixInputStream extends
java.io.InputStream {
protected java.io.InputStream in; //
the underlying InputStream
protected StringBuffer sb = null; // the StringBuffer holding input text
protected boolean isFileInputStream; // flag indicating if the
underlying InputStream is FileInputStream
protected JRelixInputStream(java.io.InputStream in) {}
public int available() throws java.io.IOException {}
public void close() throws java.io.IOException {}
public StringBuffer getText() {}
public synchronized void mark(int readlimit) {} // Marks the current
position in this input stream
public boolean markSupported() {}
public int read() throws java.io.IOException {}
public int read(byte b[]) throws java.io.IOException {}
public int read(byte b[], int off, int len) throws java.io.IOException
{}
public synchronized void reset() throws java.io.IOException {}
public
void resetIn(java.io.InputStream in) {} // Reset the underlying input stream.
public void resetText() {} // This method resets/clears the StringBuffer
holding the input text
public long skip(long n) throws java.io.IOException {} // Skips over and
discards bytes of data from the input stream.
}
5.2.21 JRelixParser class
This class is a class extends Parser class. This class wraps the Parser for better error message display.
class JRelixParser
extends Parser {
public JRelixParser(java.io.InputStream
stream) {}
public JRelixParser(ParserTokenManager tm) {}
protected void token_error()
{}// overwrites the superclass method for better error message display.
}
5.2.22 LocalInfo class
5.2.23 NREnvironment class
public class NREnvironment implements
TypeConstants {
public int row;
public Object[] data;
private NREnvironment parent;
private Environment env;
private Hashtable table;
public
int callpreEventH;
public int callpostEventH;
public NREnvironment(Relation rel, NREnvironment parent, Environment
env) {}
public NREnvironment getParent() {}
public NRInfo lookup(String name, boolean searchParent) {}
public Relation lookupRel(String name) throws InterpretError {}
public Relation lookupNestedRel(String name, int rrow) throws
InterpretError {}
public Relation lookupRelSurr(String name) throws InterpretError {}
public Relation lookupRelSurr(String name, long surrogate) throws InterpretError {}
public long getSurrogate(String name)
throws InterpretError {}
public void setSurrogate(String name, long sur) throws InterpretError {}
}
5.2.23 NREnvironment class
5.2.24 number class
This class a new data type class to represent numbers with unlimited precision.
5.2.25 ParamInfo class
class ParamInfo extends IDInfo implements
TypeConstants {
public int index;
public Relation rel; //also
stores Computation passed as parameter
public Environment env;
//pointer to the enclosing environment
public ParamInfo(int type,int index) {}
public void dump(String name) {}
public void dump(){}
}
5.2.26 Parser class
This class is automatically generated. Don’t modify this class.
5.2.27 PrettyPrint class
This class gives a format to print data.
5.2.28 Relation class
Class Relation contains all the data/methods for a relation.
class Relation implements TypeConstants,
Constants {
public boolean DEBUG = false;
protected Environment myEnv; //Pointer to the frame of the environment
public String name; // name
of the relation
public int active; // state
of the event handler, active = 0/1
public int rvc; //
RELATION, VIEW or COMPUTATION
public int numtuples; //
number of tuples
public int numattrs;// number of attributes
public int numsortattrs; //
number of sorted attributes
public SimpleNode tree; //
reference to the root of AST
public Domain[] domains; //
array of Domain objects
public Object[] data; // array of columns, data of relation
public int capacity; // capacity
of the array of column
static final int BUFFERSIZE = 32768;
// 32K
static final public boolean
isSigmaJoinImplemented = true;
public Relation() {}
public Relation(String name, Domain[] domains, int rvc, int tuples, int
attributes, int sort, SimpleNode root, Environment env) {}
public Relation(String name, Domain[] domains, int tuples, int
attributes, int sort, Environment env) {}
public Relation (Environment env) {}
public void append(Object[] dataArray, int
tuples) throws InterpretError {} //appends some tuples in the data array
to the relation
public void appendInRAM(Relation relr, Relation rell) throws
InterpretError {}// Append relation relr to relation rell, the duplicate is
eliminated.
public void appendInRAM2(Relation relr, Relation rell) throws InterpretError {} // Append relation relr to relation rell,
the duplicate is NOT eliminated.
public Relation assign(Domain[] domsr, String newname, Domain[]
domsl) throws InterpretError {} //
Assign this relation to a new relation with newname
public void assignAdd(Domain[] domsr, Relation rell, Domain[] domsl)
throws InterpretError {} // Assign & add this relation to relation rell,
note that relation rell
private void buildHeap(int[] atypes, boolean[] flags) throws InterpretError {}
private int compareRelation(Relation rel) throws InterpretError {} // compare this relation with relation rel
public int compareTwoRows(Object[] datal, int m, Object[] datar, int n,
int len, int[] types, boolean[] flags, Domain[] domsl, Domain[] domsr) throws
InterpretError {}
private int compareTwoStrings(String m, String n) {} // compare two strings which are possibly dk
and dc.
public static Object[] createDataArray(Domain[] doms, int rows){} // create the data array according to the
domain array
public void createDataArray(int rows) {}
public Relation duplicate(boolean ifload) throws InterpretError {}
public Relation duplicateLoadAll()
throws InterpretError {} // Duplicate this relation as a working copy
protected boolean existDuplicateDomain(Domain[] doms) { }
public void extract(long surrNo, Relation rel) {} // put the rows with
corresponding surrogate number into a relation
private int find(long[] surArray, long surr, int numtuples){} // find
the one position of surr in array surArray
public Relation getRelation(long surr)
throws InterpretError {}
public Relation getRelwithSurr(long surr) throws InterpretError{}
public Relation getRelExceptSurr(long surr, String relName) throws InterpretError{}
private void heapify(int n, int size, int[] atypes, boolean[]
flags) throws InterpretError {}
public void heapSort(Domain[] doms, boolean[] flags) throws InterpretError {} //for flat
relation
public int indexOfDomain(Domain dom) {} // find the index of domain dom
in the domain array in this relation
public void insert(long surrNo, Relation rel) throws InterpretError //Add
a tuple into a nested relation using surrogate number
private boolean isDkIn(Object[] dataArray, int index, int len, int[]
types) {} // check if dk exists
public boolean isDomainIn(Domain dom) {} // check if domain dom is an
element of the domain array of this relation
public boolean isDomainIn(Domain dom, Domain[] dlist) {} // check if one domain dom is in domain
array dlist
public boolean isDomainsIn(Domain[] doms) {}
public boolean isDomainsIn(Domain[] doms, Domain[] dlist) {}
public
boolean isLoaded()
public static String strRead(DataInputStream fin, int Type) throws
IOException {} // read one field from input file fin.
public static String strRead(BlockInputStream fin, int Type) throws
IOException {}
public
void load() throws InterpretError
{} // load data from disk file
public void load(boolean ifcheck)
throws InterpretError {}
public void loadAll(Relation rel)
throws InterpretError {}
public Relation mujoin(int opcode, Domain[] doml, Relation relr,Domain[]
domr, String relname) throws
InterpretError {}
public Domain[] mujoinType(int opcode, Domain[] doml, Relation relr,
Domain[] domr) throws InterpretError{}
private void shuffleDoms(Domain[] dj, Domain[] toShuffle){} // rearrange
domains in toShuffle
public Relation pick(String relname)
throws InterpretError {} // Randomly pick one tuple
public void print() throws
InterpretError {} // print the
relation onto an OutputStream
public void print(int[] lens, boolean flag) throws InterpretError {}
public void project(Domain[] doms)
throws InterpretError {} // Project the relation
public Relation project(Domain[] doms, String relname) throws InterpretError {}
public Relation renameTo(String newname) throws InterpretError {}
public void save() throws
InterpretError {} // save data onto
disk file
private void select(int index){}
public Relation select(Domain dom, int num, String relname) throws InterpretError {} //select rows
public Relation select(Domain dom, String relname) throws InterpretError {}
public void setName(String name) {}
public void setEnv(Environment newEnv)
{ }
public void sort(Domain[] doms)
throws InterpretError {}
public void sort(Domain[] doms, boolean[] flags) throws InterpretError {}
public void swapColumns(Domain[] doms)
{} // swap the domain and data array
public void swapTwoRows(int m, int n) {} // swap two rows indexed by m
and n respectively
public int[] toTypes(Domain[] doms) {}
public int[] toTypes2(Domain[] doms) {}
public void unload() {} // unload the data
public void unloadAll(Relation rel)
throws InterpretError {}// unload the data for relation rel and all the
nested relations
private
void writeAttributes(BlockOutputStream bout, Object[] dataArray, int index,
int[] types, boolean[] flags) throws
IOException {} // write a tuple to
BlockOutputStream
private void writeDcAttributes(BlockOutputStream bout, int[] types,
boolean[] flags, int offset) throws
IOException {} // write a dc's to BlockOutputStream
public void printdata() throws InterpretError {}
public Relation AttribsOf(String relname) throws InterpretError {} // creates a relation
public Domain[] sigmaJoinType(int opcode, Domain[] doml, Relation relr,
Domain[] domr) throws InterpretError {}
public Relation sigmaJoin(int opcode, Domain[] doml,Relation relr,
Domain[] domr, String relname) throws InterpretError {}
private Domain[] nonJoinDomains(Domain[] allDomains,Domain[]
joinDomains) {} //Returns a domain
array whose elements are the grouping/non-join domains for sigma-join
protected boolean isSigmaJoinTupleTrue(int sigmaJoinOpcode, boolean
isSup, boolean isSub, boolean isSep) throws InterpretError {}
public int compareTwoRowsWithDk(Object[] datal, int m, Object[] datar,
int n,int len, int[] types, boolean[] flags, Domain[] domsl, Domain[] domsr)
throws InterpretError {}
public int compareTwoRowsWithDataOffset(Object[] datal, int m, Object[]
datar, int n, int len, int[] types, boolean[] flags, Domain[] domsl, Domain[]
domsr,int leftJoinDataOffset, int rightJoinDataOffset) throws InterpretError {}
public void noloadprintdata() throws InterpretError {}
public boolean isBoolCompatible()
{}
public boolean boolCompatibleValue()
throws InterpretError {}
5.2.29 RelInfo class
5.2.30 RelTable class
This class stores and accesses .rel system relation in memory. The .rel system relation is as follows:
.rel(.name .numattribs .numtuples .vrc .tree .persistent)
* .name identifier for the relation
* .numattribs number of attributes the relation is defined on
* .numtuples number of tuples in the relation
* .vrc indicates whether this is a view, a relation or a comp
* .tree root of syntax tree of code if virtual, NULL otherwise
* .persistent boolean flag indicating if this relation is persistent
Some information from the .rd system table is kept in this RelTable class. This also includes the information describing what domains belong to each relation. The .rd system relation is as follows:
.rd(.relname .domname .count .dompos .sortrank)
* .name identifier for the relation or domain
* .attribute identifier for an attribute of the relation or domain
* .drc indicates if this identifier is a domain, relation or a comp
* .count number of different values of the domain in this relation
* .dompos index of first byte of domain in the relation
* .sortrank position of domain in sort list
public class RelTable implements
TypeConstants,Constants {
private static final int
BUF_SIZE = 16 * 1024;
private static final String REL_NAME
= ".rel";
private static final String RD_NAME
= ".rd";
private static final String VIEW_NAME = ".view";
private static final String COMP_NAME = ".comp";
private Hashtable table; // A hash table storing all the relation
entries.
public RelTable(Environment env, boolean load) {}// Initialize the hash
table, and load relation information
private void addRel(String name, int numTuples, int numAttr, int rvc, int sort, Environment env) {}
public void addRel(Relation rel, boolean incNumRef) {}
public void dump() {}
public void fillExprTable(Hashtable exprTable) {} // Fill the exprtable
public Relation getRel(String name) {}
public void insertIDlist(String relname, Domain[] doms){ }Insert the
idlist information from file .rd to RelTable.
public void insertIDlist(String relname, Domain doment, int pos) {} // Insert
the idlist information from file .rd to RelTable.
private boolean isRel(String name){ }// Check if a relation exists.
public Enumeration keys()
public void load(Environment env) {}// Load the ascii system files .rel,
and .comp into memory
public void rmRel(String name){} // Delete a
relation from the RelTable.
public void showTable(boolean flag) {}
public Hashtable getRelTable() {}
public int getRelTableSize() {} // provide number of tuples in .rel
public int getRDTableSize() {} // provide rdTable size
}
5.2.30
SemanticChecker class
The purpose of this class is to collect methods used for checking the semantics of user code. These methods should all be public and static.
class SemanticChecker implements Constants {
private static void SC_CompCommand(SimpleNode stmt, Environment
env) throws SemanticCheckError {}
private static void SC_CompAssignment(SimpleNode stmt, Environment
env) throws SemanticCheckError {}
private static void SC_CompDeclaration(SimpleNode stmt, Environment
env) throws SemanticCheckError {}
private static void SC_CompStatement(SimpleNode stmt, Environment
env) throws SemanticCheckError {}
private static void SC_CompUpdate(SimpleNode stmt, Environment env) throws SemanticCheckError{}
public static void SC_Computation(SimpleNode stmt, Environment env) throws SemanticCheckError {} // check
computations
}
5.2.31 SemanticCheckError class
This class is an Exception for semantic checking.
public class SemanticCheckError extends Exception
{
public SemanticCheckError()
public SemanticCheckError(String s)
}
5.2.31 SimpleNode class
A syntax tree is represented by simpleNode class. The syntax tree can be decomposed recursively from top down into a number of sub-trees, each of which represents a jRelix expression, statement or operator. At the extreme end of such decomposition are nodes. The following example shows a virtual domain declaration.
Example: jRelix virtual domain declaration:
let a be b+c;
The SimpleNode class describe a node in the syntax tree. Since a node contains references to both its children and its parent, it is possible to traverse a syntax tree (or part of it) in both ways. The information kept with a node object is frequently used by the Interpreter class and other classes. The SimpleNode class is therefore one of the most important classes in jRelix system.
public class SimpleNode implements Node,
java.io.Serializable,Constants, TypeConstants{
protected Node parent;
protected java.util.Vector children;
protected String identifier;
protected Object info;
protected int type;
protected int opcode;
protected String name;
protected int bits; //bits
for order or existance of options
protected java.util.Vector list;
protected int active; // active
= 1/0, for event handler, on/off
protected String url;
public SimpleNode(String id) {}
public void dump( PrintWriter out ) throws IOException {} dump the sub
parser tree to a text file
public void dump( PrintWriter out,String URL ,Environment env) throws
IOException,InterpretError {}
public SimpleNode updateChangeDump( PrintWriter out ) throws IOException
{}
public void dump(String prefix) {}
public Object getInfo() { }
public Object getObject() {}
public boolean isBitSet(int pos) {}
public void jjtAddChild(Node n) {}
public void jjtAddChildAtHead(Node n) {}
public void jjtClose() {}
public
static Node jjtCreate(String id) {}
public static SimpleNode jjtCreateNode(String id, int type, int opcode,
String name) {}
public SimpleNode jjtDeepDuplicate() {}
public SimpleNode jjtDuplicate(){ } // Duplicate a new node.
public Node jjtGetChild(int i) {}
public int jjtGetNumChildren() {}
public Node jjtGetParent() {}
public void jjtOpen() {}
public Node jjtRemoveChild(int i) {}
// remove and return child indexed by i
public void jjtReplace(SimpleNode n){
public void jjtReplaceChild(int i, Node node)
{}// replace a child with the one indexed as i in this node
public void jjtSetParent(Node n) {}
public void set(int t, int op) {}
public void set(int t, int op, String s) {}
public void set(String u,int t, int op) {}
public
void set(String u, int t, int op, String s) {}
public void setBit(int pos) {}
public void setInfo(Object i) {}
public void setObject(java.lang.Object o) { }
public String toString() {}
public String toString(String prefix) {}
public boolean hasDomain(String domName){}// Check if the name is in the
virtual domain tree
}
5.2.32 StateInfo class
class StateInfo extends StateInfo_2002
implements TypeConstants {
public int index;
public
Relation rel;//REVISIT: this should go ??
public Environment env;
//pointer to the enclosing environment
public StateInfo(int type,int index) {}
public void dump(String name){}
public void dump(){}
}
5.2.33 StateInfo_2002 class
class StateInfo_2002 extends IDInfo
implements TypeConstants {
public int intVal = 0;
public long longVal = 0;
public float floatVal = 0;
public double doubleVal = 0;
public String stringVal = "";
public Relation relVal = null; //for storing IDLIST typed states
public number numberVal = new number("+000+0");
public void setVal(int type, Object val) throws InterpretError {}
public Object getVal(int type) throws InterpretError {}
public void dump(int type) throws InterpretError {}
public void dump() {}
}
5.2.34 Surrogate class
This class implements the algorithm for loading and storing of surrogate value from and to disk. Surrogates are generated by the system. At first, jRelix system generates 0 to a surrogate. Then, when using it, jRelix system will increase the surrogate by one for next turn. They are all different for one database inorder to avoid conflict. We use long integers as surrogates. Since the largest long integer is about 9.2E+18, it will wrap after 292,471 years, assuming that the surrogates are generated at a speed of 1,000,000 per second. To ensure that the surrogates are uniquely defined over the lifetime of a database, we make it persistent by storing it on disk. Its value is loaded from the disk before using it. Before storing a relation that contains surrogates, we always dump the current value of the surrogate onto disk.
}
5.3.1
JRelix system excution order:
5.3.2
Relation
implement: extend: use:
RelTable Enviroment SimpleNode Domain Relation
5.3.3
Domain
RelTable Environment DomTable Domain SimpleNode
5.3.4
Computation
SimpleNode Enviroment Interpreter Domain
Relation
5.3.5
Trigger
TriggerNode CTrigger Relation Enviroment
5.3.6
Expression
EvalExpr Interpreter Enviroment RelTable DomTable CompTable
5.3.7
ID information
TypeConstants RelInfo DomInfo NRInfo LocalInfo ParamInfo
This guide is a general documentation for developer. From it, developer can get the whole system idea. But, if you want to improve the jRelix system, you should know the detail code where will give you the detail implementation and you can consult all project/ thesis document in Prof. Tim website: http://www.cs.mcgill.ca/~tim/cv/students.html.
[JavaCC] Oliver Enseling. JavaCC tutorial.
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-cooltools.html
[jRelix] Aldat Lab, Computer Science, McGill
University. JRelix system java code.