Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1592/compiler/algebra

Modified Files:
      Tag: Nov2009
        logical.c 
Log Message:
propagated changes of Monday Sep 28 2009 - Wednesday Oct 07 2009
from the Aug2009_NFI branch to the Nov2009 branch

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/09/28 - boncz: compiler/algebra/logical.c,1.126.6.1
  optimizations for NFI XIRAF use case -- thanks a great bunch Jan R.!!
  
  - ds_link (already in Stable) optimized for 1-node case
  - indices now contain all data (but still not used automatically, nor based 
on Lefteris' new indexing schemes)
  
  most prominently though is: subexpression result caching
  - caching hints in pragmas
  - query enclosed in (# pf:session id:msec ) { query }  or (# pf:session-use 
id:msec ) { query }
    + queries in the same session use the same working set (documents opened 
only once)
    + same working set allows to cache results
    + pf:session-use only uses cache, cannot add to it
      - but, multiple pf:session-use can run concurrently; whereas pf:session 
is exclusive
  - inside a query, an arbitrary number of expressions can be marked up for 
caching/reuse
    + (# pf:cache id ) { subexpr }
    + subexpr may not be enclosed by a for-loop
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/10/06 - boncz: compiler/algebra/logical.c,1.126.6.2
  enable heuristic rewrite value-selections in the algebra backend of 
MonetDB/xQuery
  
  has to properly implement pf:attribute(ctx, node, ns1, loc1, ns2, loc2) first,
  as only the verion without namespaces was there (that one is now gone).
  
  many restrictions:
  - only non-loop-lifted equality tests
  - not involving fn:collection or pf:collection (as path reversal in the 
latter will never find the supernode)
  - not involving any date/time/etc typed expressions (as the indices only work 
for string and numerical equality)
  
  went through the testweb and fixed all apparant problems
  
  note the Aug2009_NFI value indices are full; whereas previously they would 
omit frequent data items
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


U logical.c
Index: logical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/logical.c,v
retrieving revision 1.126
retrieving revision 1.126.4.1
diff -u -d -r1.126 -r1.126.4.1
--- logical.c   12 Jun 2009 13:06:09 -0000      1.126
+++ logical.c   7 Oct 2009 13:44:02 -0000       1.126.4.1
@@ -265,8 +265,9 @@
  * or below a `rec_fix' operator if the side effects appear in the recursion
  * body.
  * The `side_effects' operator contains a (possibly empty) list of operations
- * that may trigger side effects (operators `error' and `trace') in its left
- * child and the fragment or recursion parameters in the right child.
+ * that may trigger side effects (operators `error', `cache' and `trace')
+ * in its left child and the fragment or recursion parameters in the right
+ * child.
  */
 PFla_op_t *
 PFla_side_effects (const PFla_op_t *side_effects, const PFla_op_t *params)
@@ -275,6 +276,7 @@
 
     assert (side_effects);
     assert (side_effects->kind == la_error ||
+            side_effects->kind == la_cache ||
             side_effects->kind == la_trace ||
             side_effects->kind == la_nil);
     assert (params);
@@ -2976,7 +2978,8 @@
 PFla_doc_index_join (const PFla_op_t *doc, const PFla_op_t *n,
                      PFla_doc_join_kind_t kind,
                      PFalg_col_t item,
-                     PFalg_col_t item_res, PFalg_col_t item_doc)
+                     PFalg_col_t item_res, PFalg_col_t item_doc,
+                     const char* ns1, const char* loc1, const char* ns2, const 
char* loc2)
 {
     PFla_op_t    *ret;
     unsigned int  i;
@@ -2991,6 +2994,10 @@
     ret->sem.doc_join.item     = item;
     ret->sem.doc_join.item_res = item_res;
     ret->sem.doc_join.item_doc = item_doc;
+    ret->sem.doc_join.ns1      = ns1;
+    ret->sem.doc_join.loc1     = loc1;
+    ret->sem.doc_join.ns2      = ns2;
+    ret->sem.doc_join.loc2     = loc2;
 
 #ifndef NDEBUG
     if (PFprop_ocol (n, item_res))
@@ -3616,6 +3623,40 @@
 
 
 /**
+ * Constructor for a caching operator.
+ *
+ * This operator puts a query to the query cache (with the key in @a id).
+ */
+PFla_op_t *
+PFla_cache (const PFla_op_t *n1, const PFla_op_t *n2, char *id,
+            PFalg_col_t pos, PFalg_col_t item)
+{
+    PFla_op_t   *ret;
+    unsigned int i;
+
+    assert(n1);
+
+    ret = la_op_wire2 (la_cache, n1, n2);
+
+    /* allocate memory for the result schema; it's the same schema as n's */
+    ret->schema.count = n2->schema.count;
+    ret->schema.items
+        = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items)));
+
+    /* copy schema from argument 'n' */
+    for (i = 0; i < n2->schema.count; i++) {
+        ret->schema.items[i] = n2->schema.items[i];
+    }
+
+    ret->sem.cache.id   = id;
+    ret->sem.cache.pos  = pos;
+    ret->sem.cache.item = item;
+
+    return ret;
+}
+
+
+/**
  * Constructor for a debug operator
  */
 PFla_op_t *
@@ -4360,7 +4401,11 @@
                                         n->sem.doc_join.kind,
                                         n->sem.doc_join.item,
                                         n->sem.doc_join.item_res,
-                                        n->sem.doc_join.item_doc);
+                                        n->sem.doc_join.item_doc,
+                                        n->sem.doc_join.ns1,
+                                        n->sem.doc_join.loc1,
+                                        n->sem.doc_join.ns2,
+                                        n->sem.doc_join.loc2);
 
         case la_doc_tbl:
             return PFla_doc_tbl (left,
@@ -4452,6 +4497,13 @@
         case la_nil:
             return PFla_nil ();
 
+        case la_cache:
+            return PFla_cache (left,
+                               right,
+                               n->sem.cache.id,
+                               n->sem.cache.pos,
+                               n->sem.cache.item);
+
         case la_trace:
             return PFla_trace (left, right);
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to