220 likes | 242 Vues
XQuery with User-defined Functions. David Bedn árek david.bednarek@mff.cuni.cz ulita.ms.mff.cuni.cz/~bednarek Department of Software Engineering Faculty of Mathematics and Physics Charles University Prague. XQuery program with user-defined functions. declare function local:toc($P) {
E N D
XQuery with User-defined Functions David Bednárek david.bednarek@mff.cuni.cz ulita.ms.mff.cuni.cz/~bednarek Department of Software Engineering Faculty of Mathematics and Physics Charles University Prague
XQuery program with user-defined functions declare function local:toc($P) { for $X in $P/section return <section> { $X/@* , $X/title , local:toc($X) } </section> }; <toc> { for $S in $I/book return local:toc($S) } </toc>
XQuery with user-defined functions • Turing-complete language • Identification of patterns of "strong" computation • Relational algebra representation • Identifier handling • Bulk-evaluation • R-programs • Temporary structures • Static analysis • Generation of the output document • Reversed evaluation
Turing-completeness of XQuery • Identification of patterns of "strong" computation
The simplest XQuery application • XML document tree A 4 1 2 B 3 C D • XQuery evaluation tree
The simplest XQuery application • Cartesian product A 4 1 2 B 3 C D
The simplest XQuery application • Two-dimensional attribute grammar • Dependence analysis
The simplest XQuery application • Turing-strong patterns • Mesh • Tape
Relational algebra representation • Identifier handling
XQuery program and its effect on encoded documents declare function local:toc($P) { for $X in $P/section return <section> { $X/@* , $X/title , local:toc($X) } </section> }; <toc> { for $S in $I/book return local:toc($S) } </toc>
Bulk-evaluation • R-programs
R-programs • Handling recursion by expansion • Bulk-evaluation by relational algebra
R-programs • DAG of relational algebra operators • Gradual expansion driven by triggers
Temporary structures • Static analysis • Published in: • "Reducing Temporary Trees in XQuery" • ADBIS 2008, Pori, Finland, LNCS
Static analysis algorithm • Input: a XQuery program • Output: a set of modes assigned to each sub-expression and each variable • Mode determines a particular way of representation required • Reversed evaluation is one of the modes • Time O(n2), space O(n)
Generation of the output document • Reversed evaluation • Published in: • "Output-driven evaluation of XQuery" • IDC 2008, Catania, Italy, Springer Verlag
Standard data flow declare function local:toc($P) { for $X in $P/section return <section> { $X/@* , $X/title , local:toc($X) } </section> }; <toc> { for $S in $I/book return local:toc($S) } </toc>
Future work • Cost-based optimization in R-programs • Distributed/parallel XQuery engine