Execution Engine
Contact: Ramana Yerneni (yerneni@db.stanford.edu)

The execution engine is part of the Tsimmis mediators and wrappers. In the mediators, it provides a simple interface to pass it a query plan to be executed. It returns the results of executing the query plan as a top-level answer object which points to all the answers in the query plan. In the wrappers, it provides a simple interface to pass it the filter query and answers obtained from the source. It returns the the results of filtering the source answers with respect to the filter query.

The function invoked by the mediators to execute the plan is Execute. The function invoked by the wrappers to filter the source answer is PostProcess.

The declarations of Execute and PostProcess functions are in ~tsimmis/tsimmis-1.0/src/common/exec.h". These functions are defined in ~tsimmis/tsimmis-1.0/src/mediators/engine/aix/exec.c. The data structures used by the engine are defined in pdp.h and tmtypes.h, which reside in ~tsimmis/tsimmis-1.0/src/common/.

Execution Engine Interface

The following are the functions provided by the execution engine:

  1. Query: By calling the following function, one can execute the issue of a query to the wrapper and the collection of the answer objects in a table.
    	   Table Query(char *query, char *source, int &error);
               
  2. Extract: By calling the following function, one can extract the bindings of the variables of a template with respect to the answer objects of the corresponding query.
    	   Table Extract(Table &table, int schemalen, int *schema, 
    			 condlisttype *condlist, int colindex,
    			 int oschemalen, int *oschema, int &error);
               
  3. ParamQuery: By calling the following function, one can issue a parameterized query to a wrapper and collect the answer objects in a table.
    	   Table ParamQuery(char *query, char *source, 
    			    Table &table, int schemalen, int *schema,
    			    int paramnum, int *paramvars, int &error);
               
  4. Union: By calling the following function, one can perform the union of a list of bindings tables.
    	   Table Union(Table **tablelist, int unionnum, int &error);
               
  5. Join: By calling the following function, one can perform the join (a simple nested loop one) of two tables.
    	   Table Join(Table &table1, int schemalen1, int *schema1,
    		      Table &table2, int schemalen2, int *schema2,
    		      int joinlen, int *joinschema, int &error);
               
  6. SortJoin: By calling the following function, one can perform a sortjoin of two tables.
    	   Table SortJoin(Table &table1, int schemalen1, int *schema1,
    		      Table &table2, int schemalen2, int *schema2,
    		      int joinlen, int *joinschema, int &error);
               
  7. Project: By calling the following function, one can project a table of bindings onto a set of variables.
    	   Table Project(Table &table, int schemalen, int *schema,
    			 int oschemalen, int *oschema, int &error);
               
  8. Filter: By calling the following function, one can filter a table of bindings with a condition that equates a variable to a string value.
    	   Table Filter(Table &table, int schemalen, int *schema, 
    			int variable, char *value, int &error);
               
  9. Construct: By calling the following function, one can construct answer objects (a top level object having the answer objects as children) from the bindings table and a header template.
    	   TM_Object *Construct(consobjtype *anstemplate,
    			Table &table, int schemalen, int *schema,
    			int &error);
               

Note: All of the above functions return an error value through the "error" parameter. If this is not equal to 0, the return value of the function (be it a table or a TM_Object pointer) is undefined.

Features

  1. Built-In Predicates:
    The engine supports the following builtin predicates: eq, ne, lt, le, gt, ge, contains (with the obvious semantics). The predicate names as well as their constant arguments are treated in a case insensitive manner. For example, contains(X,"AbC") is true if X is "...abC..." and so are contains(X, "ABC"), contains(X,"abc"), etc.

    To use builtin predicates, they should be included in the condition list (see condlisttype in pdp.h) that is passed to the PostProcess function (in the case of Wrappers) and as part of the EXTRACT node in the query plan that is passed to the Execute function (in the case of the Mediators). Each predicate is specified in the condlist structure as having exactly two arguments, the first being a variable and the second being a variable or a constant. In all other cases, the engine will return error.

    The graph traversal of the query plan is now part of the execution engine and hence there is no need for access to the engine operations like Extract, Construct and Join. Now the engine interface has only two functions: PostProcess (Wrappers should call this) and Execute (Mediators should call this). Please see ~tsimmis/tsimmis-1.0/src/common/exec.h for the new execution engine interface.