Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31501/compiler/algebra
Modified Files:
Tag: M5XQ
builtins.c
Log Message:
propagated changes of Monday Oct 05 2009
from the development trunk to the M5XQ branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/05 - sjoerd: compiler/algebra/builtins.c,1.128
propagated changes of Monday Sep 28 2009 - Monday Oct 05 2009
from the Aug2009_NFI branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/09/28 - boncz: compiler/algebra/builtins.c,1.126.2.1.2.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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
U builtins.c
Index: builtins.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
retrieving revision 1.121.2.5
retrieving revision 1.121.2.6
diff -u -d -r1.121.2.5 -r1.121.2.6
--- builtins.c 8 Sep 2009 08:05:29 -0000 1.121.2.5
+++ builtins.c 5 Oct 2009 12:11:35 -0000 1.121.2.6
@@ -5794,6 +5794,62 @@
}
/**
+ * Algebra implementation for pragma pf:cache.
+ */
+struct PFla_pair_t
+PFbui_pf_query_cache (const PFla_op_t *loop,
+ bool ordering,
+ PFla_op_t **side_effects,
+ struct PFla_pair_t *args)
+{
+ (void) ordering;
+
+ /* We do forbidden side effects here --- They however don't harm us. */
+ PFprop_infer_card ((PFla_op_t *) loop);
+
+ /* If we are inside an iteration discard caching. */
+ if (PFprop_card(loop->prop) != 1)
+ return args[1];
+
+ /* Otherwise introduce a side effect for the caching and replace
+ the query by a cache lookup. */
+ else {
+ PFalg_simple_type_t ty = PFprop_type_of (args[1].rel, col_item);
+ char *id;
+ /* extract the id information */
+ PFprop_infer_const (args[0].rel);
+ assert (PFprop_const (args[0].rel->prop, col_item));
+ id = (PFprop_const_val (args[0].rel->prop, col_item)).val.str;
+
+ /* Provide a (possibly) new cache as side effect. */
+ *side_effects = cache (
+ *side_effects,
+ args[1].rel,
+ id,
+ col_pos,
+ col_item);
+
+ /* Use a cache lookup as the replacement. */
+ PFla_op_t *res = fun_call (loop, /* loop relation */
+ fun_param (args[0].rel, /* query cache id */
+ nil(),
+ ipi_schema(aat_str)),
+ ipi_schema(ty), /* i|p|i schema */
+ alg_fun_call_cache, /* function kind */
+ PFqname (PFns_wild, NULL), /* qname */
+ NULL, /* ctx */
+ col_iter, /* iter */
+ alg_occ_unknown); /* occurrence indicator */
+
+ return (struct PFla_pair_t) {
+ .rel = res,
+ .frag = (ty & aat_node)
+ ? PFla_set (frag_extract (res, 2))
+ : PFla_empty_set () };
+ }
+}
+
+/**
* The fs:distinct-doc-order function sorts its input sequence of
* nodes by document order and removes duplicates.
*/
@@ -6460,8 +6516,7 @@
.rel = rank (res,
col_pos,
sortby (col_item)),
- /* FIXME: if uncomment the next line there is a seqmentation fault */
- .frag = PFla_empty_set() }; /* PFla_set (frag_extract (res, 2)) }; */
+ .frag = PFla_set (frag_extract (res, 1)) };
}
/**
@@ -6488,8 +6543,7 @@
.rel = rank (res,
col_pos,
sortby (col_item)),
- /* FIXME: if uncomment the next line, a seqmentation fault appears */
- .frag = PFla_empty_set() }; /* PFla_set (frag_extract (res, 2)) }; */
+ .frag = PFla_set (frag_extract (res, 1)) };
}
/**
------------------------------------------------------------------------------
Come build with us! The BlackBerry® 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/devconf
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins