Update of /cvsroot/monetdb/pathfinder/compiler/include
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14484/include
Modified Files:
algebra.h logical.h logical_mnemonic.h
Log Message:
-- Implemented generic function application facility (for the logical algebra).
Generic functions can now be implemented in the logical algebra using
the following 4 operators:
o la_fun_call:
The head of a function call whose left child is the loop relation and the
right child a function parameter list. The operator is prepared for a set
of different kinds (e.g., xrpc and tijah), stores the function name and a
pointer to an arbitrary context (for XRPC this is a reference to the core
apply node).
o la_fun_param:
An item of the function parameter list refering to an algebra expression
(left child) and to the rest of the function parameter list (right child).
Its schema stores the names of all input columns. The order of columns
in the schema is important!
o la_fun_frag_param:
An item of the function parameter list refering to a fragment (left child)
and to the rest of the function parameter list (right child). It has a
further position argument that indicates to which column of the next
la_fun_param operator in the right child the fragment information refers
to. This operator is only used if a column contains node references.
o la_frag_extract:
If a function call returns nodes a frag_extract operator sits on top of
the la_fun_call operator to fix the fragment information needed by our
compilation scheme. Similar to the la_fun_frag_param operator it stores
the schema position of the item column it refers to.
Index: algebra.h
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/include/algebra.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- algebra.h 20 Nov 2007 16:57:26 -0000 1.64
+++ algebra.h 13 Dec 2007 13:08:17 -0000 1.65
@@ -263,6 +263,24 @@
};
typedef struct PFalg_scj_spec_t PFalg_scj_spec_t;
+/** function call result occurrence indicator */
+enum PFalg_occ_ind_t {
+ alg_occ_unknown /**< unknown result size */
+ , alg_occ_zero_or_one /**< zero or one tuple per iteration */
+ , alg_occ_exactly_one /**< exactly one tuple per iteration */
+ , alg_occ_one_or_more /**< one or more tuples per iteration */
+};
+typedef enum PFalg_occ_ind_t PFalg_occ_ind_t;
+
+/** function call representatives */
+enum PFalg_fun_call_t {
+ alg_fun_call_dft /**< normal function call */
+ , alg_fun_call_xrpc /**< XRPC function call */
+ , alg_fun_call_xrpc_helpers /**< function call for XRPC helpers */
+ , alg_fun_call_tijah /**< Tijah function call */
+};
+typedef enum PFalg_fun_call_t PFalg_fun_call_t;
+
/** function representatives */
enum PFalg_fun_t {
alg_fun_num_add /**< arithmetic plus operator */
@@ -443,6 +461,21 @@
char * PFalg_simple_type_str (PFalg_simple_type_t att);
/**
+ * Print function call kind
+ */
+char * PFalg_fun_call_kind_str (PFalg_fun_call_t kind);
+
+/**
+ * Extract all possible algebra types from the XQuery type.
+ */
+PFalg_simple_type_t PFalg_type (PFty_t ty);
+
+/**
+ * Extract occurrence indicator from the XQuery type.
+ */
+PFalg_occ_ind_t PFalg_type_occ (PFty_t ty);
+
+/**
* Print function name
*/
char * PFalg_fun_str (PFalg_fun_t fun);
Index: logical_mnemonic.h
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/include/logical_mnemonic.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- logical_mnemonic.h 10 Dec 2007 15:10:04 -0000 1.30
+++ logical_mnemonic.h 13 Dec 2007 13:08:18 -0000 1.31
@@ -194,6 +194,9 @@
/** constructor for a new fragment, containing newly ceated xml nodes */
#define fragment(a) PFla_fragment ((a))
+/** constructor for a fragment extract operator */
+#define frag_extract(a,b) PFla_frag_extract ((a),(b))
+
/** constructor for an empty fragment */
#define empty_frag() PFla_empty_frag ()
@@ -223,6 +226,12 @@
#define rec_arg(a,b,c) PFla_rec_arg ((a),(b),(c))
#define rec_base(a) PFla_rec_base (a)
+/* function application */
+#define fun_call(a,b,c,d,e,f,g,h) \
+ PFla_fun_call ((a),(b),(c),(d),(e),(f),(g),(h))
+#define fun_param(a,b,c) PFla_fun_param ((a),(b),(c))
+#define fun_frag_param(a,b,c) PFla_fun_frag_param ((a),(b),(c))
+
/* constructors for built-in functions */
#define fn_string_join(a,b,c,d,e,f,g,h,i) \
PFla_fn_string_join ((a),(b),(c),(d),(e),(f),(g),(h),(i))
Index: logical.h
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/include/logical.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- logical.h 10 Dec 2007 15:10:04 -0000 1.47
+++ logical.h 13 Dec 2007 13:08:17 -0000 1.48
@@ -95,15 +95,16 @@
- la_rowrank behaves exactly like SQLs DENSE_RANK. It is used to
generate
the group by semantics of our functional source language.
- la_rank -- beside one exception -- behaves like la_rowrank. It is also
- implemented in our SQL compilation with a DENSE_RANK operation.
la_rank's
- important difference to la_rowrank is that its resulting values are
used
- solely for ordering. No operation should ever look at the generated
values.
- While this difference is uninteresting in the resulting code it
simplifies
- the algebraic optimizer a lot. Instead of repeatedly inferring a
property
- that checks for column usage we can optimize based on the operator
kind.
- - la_rowid generates unrepeatable unique numbers (as 'ROW_NUMBER() OVER
()'
- does in SQL or 'mark()' does in MIL). It is used to generate a new key
- column. */
+ implemented in our SQL compilation with a DENSE_RANK operation.
+ la_rank's important difference to la_rowrank is that its resulting
+ values are used solely for ordering. No operation should ever look
+ at the generated values. While this difference is uninteresting
+ in the resulting code it simplifies the algebraic optimizer a lot.
+ Instead of repeatedly inferring a property that checks for column
usage
+ we can optimize based on the operator kind.
+ - la_rowid generates unrepeatable unique numbers
+ (as 'ROW_NUMBER() OVER ()' does in SQL or 'mark()' does in MIL).
+ It is used to generate a new key column. */
, la_rownum = 37 /**< consecutive number generation (ROW_NUMBER)
*/
, la_rowrank = 38 /**< consecutive number generation (DENSE_RANK)
*/
, la_rank = 39 /**< arbitrary but ordered number generation */
@@ -142,9 +143,12 @@
schema: iter | pos | item */
/* all operators below represent xml node fragments with no schema */
, la_fragment = 71 /**< representation of a node fragment */
- , la_frag_union = 72 /**< special node type used to form an algebraic
+ , la_frag_extract = 72 /**< representation of a reference to a node
+ fragment (used in combination with function
+ calls to address the resulting fragments) */
+ , la_frag_union = 73 /**< special node type used to form an algebraic
union of fragments */
- , la_empty_frag = 73 /**< representation of an empty fragment */
+ , la_empty_frag = 74 /**< representation of an empty fragment */
, la_error = 79 /**< error operator for the fn:error function*/
, la_cond_err = 80 /**< facility to trigger runtime errors */
@@ -158,6 +162,10 @@
in the recursion */
, la_rec_base = 88 /**< base of the DAG describing the recursion */
+ , la_fun_call = 90 /**< function application */
+ , la_fun_param = 91 /**< function application parameter */
+ , la_fun_frag_param = 92 /**< function application parameter */
+
, la_proxy = 96 /**< proxy operator that represents a group
of operators */
, la_proxy_base = 97 /**< completes the content of the proxy
@@ -206,7 +214,6 @@
} lit_tbl; /**< semantic content for literal table
constructor */
-
/* semantic content for tableref operator */
struct {
char* name;
@@ -215,8 +222,6 @@
(w.r.t. the schema) of key attributes */
} ref_tbl; /**< semantic content for tableref operator
*/
-
-
/* semantic content for attach operator */
struct {
PFalg_att_t res; /**< names of new attribute */
@@ -259,7 +264,7 @@
/* semantic content for selection operator */
struct {
- PFalg_att_t att; /**< name of selected attribute */
+ PFalg_att_t att; /**< name of selected attribute */
} select;
/* semantic content for positional selection operator */
@@ -273,10 +278,10 @@
/* semantic content for generic (row based) function operator */
struct {
- PFalg_fun_t kind; /**< kind of the function */
- PFalg_att_t res; /**< attribute to hold the result */
- PFalg_attlist_t refs; /**< list of attributes required
- to compute attribute res */
+ PFalg_fun_t kind; /**< kind of the function */
+ PFalg_att_t res; /**< attribute to hold the result */
+ PFalg_attlist_t refs; /**< list of attributes required
+ to compute attribute res */
} fun_1to1;
/* semantic content for binary (arithmetic and boolean) operators */
@@ -307,10 +312,10 @@
* or a boolean grouping function (seqty1, all,...)
*/
struct {
- PFalg_att_t att; /**< attribute to be used for the agg. func. */
- /* Note that 'att' is ignored by la_count */
- PFalg_att_t part; /**< partitioning attribute */
- PFalg_att_t res; /**< attribute to hold the result */
+ PFalg_att_t att; /**< column to be used for the agg. func. */
+ /* Note that 'att' is ignored by la_count
*/
+ PFalg_att_t part; /**< partitioning attribute */
+ PFalg_att_t res; /**< attribute to hold the result */
} aggr;
/* semantic content for rownumber, rowrank, and rank operator */
@@ -329,24 +334,24 @@
/* semantic content for type test, cast, and type_assert operator */
struct {
- PFalg_att_t att; /**< name of type-tested, casted or type
- asserted attribute */
- PFalg_simple_type_t ty; /**< comparison, cast, and restriction type */
- PFalg_att_t res; /**< column to store result of type test
- or cast */
+ PFalg_att_t att; /**< name of type-tested, casted or type
+ asserted attribute */
+ PFalg_simple_type_t ty; /**< comparison, cast, and restriction type
*/
+ PFalg_att_t res; /**< column to store result of type test
+ or cast */
/* Note that 'res' is ignored by la_type_assert */
} type;
/* store the semantic information for path steps (with guide information)
*/
struct {
- PFalg_axis_t axis;
- PFty_t ty;
- unsigned int guide_count;
+ PFalg_axis_t axis;
+ PFty_t ty;
+ unsigned int guide_count;
PFguide_tree_t **guides;
- int level;
- PFalg_att_t iter; /**< column to look up the iterations */
- PFalg_att_t item; /**< column to look up the context nodes */
- PFalg_att_t item_res; /**< column to store the resulting nodes */
+ int level;
+ PFalg_att_t iter; /**< column to look up the iterations */
+ PFalg_att_t item; /**< column to look up the context nodes */
+ PFalg_att_t item_res; /**< column to store the resulting nodes */
} step;
/* store the semantic information for fn:id, fn:idref, pf:text,
@@ -384,10 +389,10 @@
/* store the column names necessary for a constructor content operator */
/* semantic content for debug operator */
- struct {
- PFalg_att_t iter; /**< name of iter column */
- PFalg_att_t pos; /**< name of pos column */
- PFalg_att_t item; /**< name of item column */
+ struct {
+ PFalg_att_t iter; /**< name of iter column */
+ PFalg_att_t pos; /**< name of pos column */
+ PFalg_att_t item; /**< name of item column */
} iter_pos_item;
/* store the column names necessary for an attribute constructor */
@@ -415,32 +420,49 @@
/* semantic content for conditional error */
struct {
- PFalg_att_t att; /**< name of the boolean attribute */
- char * str; /**< error message */
+ PFalg_att_t att; /**< name of the boolean attribute */
+ char * str; /**< error message */
} err;
/* semantic content for debug relation map operator */
struct {
- PFalg_att_t inner; /**< name of the inner column */
- PFalg_att_t outer; /**< name of the outer column */
+ PFalg_att_t inner; /**< name of the inner column */
+ PFalg_att_t outer; /**< name of the outer column */
} trace_map;
/* semantic content for an argument of a recursion parameter */
struct {
- PFla_op_t *base; /**< reference to the base relation
- of the recursion */
+ PFla_op_t *base; /**< reference to the base relation
+ of the recursion */
} rec_arg;
+ struct {
+ PFalg_fun_call_t kind; /**< kind of function call */
+ PFqname_t qname; /**< function name */
+ void *ctx; /**< reference to the context node
+ representing the function call */
+ PFalg_att_t iter; /**< the loop relation */
+ PFalg_occ_ind_t occ_ind; /**< occurrence indicator for the
+ iter column of the result
+ (used for optimizations) */
+ } fun_call;
+
+ /* semantic content of the function call fragment paramter and
+ the fragment extraction operator */
+ struct {
+ unsigned int pos; /**< position of the referenced column */
+ } col_ref;
+
/* semantic content for proxy nodes */
struct {
- unsigned int kind; /**< proxy kind */
- PFla_op_t *ref; /**< reference a certain operator in the
- proxy body */
- PFla_op_t *base1; /**< the leafs first child */
- PFla_op_t *base2; /**< the leafs second child */
- PFalg_attlist_t req_cols; /**< list of columns required
- to evaluate proxy */
- PFalg_attlist_t new_cols; /**< list of new generated columns */
+ unsigned int kind; /**< proxy kind */
+ PFla_op_t *ref; /**< reference a certain operator in the
+ proxy body */
+ PFla_op_t *base1; /**< the leafs first child */
+ PFla_op_t *base2; /**< the leafs second child */
+ PFalg_attlist_t req_cols; /**< list of columns required
+ to evaluate proxy */
+ PFalg_attlist_t new_cols; /**< list of new generated columns */
} proxy;
/* store the column names necessary for a string_join operator */
@@ -1027,6 +1049,10 @@
*/
PFla_op_t * PFla_fragment (const PFla_op_t *n);
+/** Constructor for a fragment extract operator
+ (to be used in combination with a function call) */
+PFla_op_t * PFla_frag_extract (const PFla_op_t *n, unsigned int col_pos);
+
/****************** fragment set handling *******************/
@@ -1062,7 +1088,6 @@
*/
PFla_op_t *PFla_set_to_la (PFla_set_t *frags);
-
/** Form algebraic disjoint union between two fragments. */
PFla_op_t * PFla_frag_union (const PFla_op_t *n1, const PFla_op_t *n2);
@@ -1143,6 +1168,34 @@
*/
PFla_op_t *PFla_rec_base (PFalg_schema_t schema);
+/**
+ * Constructor for the function application
+ */
+PFla_op_t *PFla_fun_call (const PFla_op_t *loop,
+ const PFla_op_t *param_list,
+ PFalg_schema_t schema,
+ PFalg_fun_call_t kind,
+ PFqname_t qname,
+ void *ctx,
+ PFalg_att_t iter,
+ PFalg_occ_ind_t occ_ind);
+
+/**
+ * Constructor for a list item of a parameter list
+ * related to function application
+ */
+PFla_op_t *PFla_fun_param (const PFla_op_t *argument,
+ const PFla_op_t *param_list,
+ PFalg_schema_t schema);
+
+/**
+ * Constructor for the fragment information of a list item
+ * of a parameter list related to function application
+ */
+PFla_op_t *PFla_fun_frag_param (const PFla_op_t *argument,
+ const PFla_op_t *param_list,
+ unsigned int col_pos);
+
/****************************************************************/
/**
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins