XML and Databases. Outline. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths. 1. Top-Down Evaluation of Simple Paths

Similar documents
Lecture 3. XML Into RDBMS. XML and Databases. Memory Representations. Memory Representations. Traversals and Pre/Post-Encoding. Memory Representations

XML and Databases. Exam Preperation Discuss Answers to last year s exam. Sebastian Maneth NICTA and UNSW

Lecture 6: Coding theory

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

Lecture 11 Binary Decision Diagrams (BDDs)

Data Structures and Algorithm. Xiaoqing Zheng

CS 360 Exam 2 Fall 2014 Name

CS241 Week 6 Tutorial Solutions

Chapter 4 State-Space Planning

CS 491G Combinatorial Optimization Lecture Notes

CSC2542 State-Space Planning

6. Suppose lim = constant> 0. Which of the following does not hold?

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

Nondeterministic Finite Automata

2.4 Theoretical Foundations

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

First Midterm Examination

CS 573 Automata Theory and Formal Languages

CMSC 330: Organization of Programming Languages

I 3 2 = I I 4 = 2A

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Finite State Automata and Determinisation

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

Prefix-Free Regular-Expression Matching

Semantic Analysis. CSCI 3136 Principles of Programming Languages. Faculty of Computer Science Dalhousie University. Winter Reading: Chapter 4

Lesson 2.1 Inductive Reasoning

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Total score: /100 points

POSITIVE IMPLICATIVE AND ASSOCIATIVE FILTERS OF LATTICE IMPLICATION ALGEBRAS

Logic, Set Theory and Computability [M. Coppenbarger]

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Solutions to Problem Set #1

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

Outline Data Structures and Algorithms. Data compression. Data compression. Lossy vs. Lossless. Data Compression

Factorising FACTORISING.

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Lesson 2.1 Inductive Reasoning

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Now we must transform the original model so we can use the new parameters. = S max. Recruits

, g. Exercise 1. Generator polynomials of a convolutional code, given in binary form, are g. Solution 1.

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

Chapter 3. Vector Spaces. 3.1 Images and Image Arithmetic

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

Graph Algorithms. Vertex set = { a,b,c,d } Edge set = { {a,c}, {b,c}, {c,d}, {b,d}} Figure 1: An example for a simple graph

NON-DETERMINISTIC FSA

Linear Algebra Introduction

Minimal DFA. minimal DFA for L starting from any other

Instructions. An 8.5 x 11 Cheat Sheet may also be used as an aid for this test. MUST be original handwriting.

Propositional models. Historical models of computation. Application: binary addition. Boolean functions. Implementation using switches.

University of Sioux Falls. MAT204/205 Calculus I/II

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths

System Validation (IN4387) November 2, 2012, 14:00-17:00

AP CALCULUS Test #6: Unit #6 Basic Integration and Applications

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Implication Graphs and Logic Testing

Regular expressions, Finite Automata, transition graphs are all the same!!

Coding Techniques. Manjunatha. P. Professor Dept. of ECE. June 28, J.N.N. College of Engineering, Shimoga.

Eigenvectors and Eigenvalues

Where did dynamic programming come from?

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

SEMANTIC ANALYSIS PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/28

Equivalent fractions have the same value but they have different denominators. This means they have been divided into a different number of parts.

Applied. Grade 9 Assessment of Mathematics. Multiple-Choice Items. Winter 2005

Ling 3701H / Psych 3371H: Lecture Notes 9 Hierarchic Sequential Prediction

XPath Node Selection over Grammar-Compressed Trees

Welcome. Balanced search trees. Balanced Search Trees. Inge Li Gørtz

CIT 596 Theory of Computation 1. Graphs and Digraphs

SIMPLE NONLINEAR GRAPHS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

First Midterm Examination

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Convert the NFA into DFA

Discrete Structures Lecture 11

Time/Space Efficient Filtering of Streaming XML Documents Using Incrementally Constructed c

CS 275 Automata and Formal Language Theory

Finite-State Automata: Recap

A Rewrite Approach for Pattern Containment

COMPUTING THE QUARTET DISTANCE BETWEEN EVOLUTIONARY TREES OF BOUNDED DEGREE

Computational Biology Lecture 18: Genome rearrangements, finding maximal matches Saad Mneimneh

Unit 4. Combinational Circuits

EE 108A Lecture 2 (c) W. J. Dally and P. Levis 2

Compiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

COMPUTING THE QUARTET DISTANCE BETWEEN EVOLUTIONARY TREES OF BOUNDED DEGREE

Module 9: Tries and String Matching

Module 9: Tries and String Matching

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

Formal languages, automata, and theory of computation

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

H SERIES. Algebra Basics. Algebra Basics. Solutions. Curriculum Ready.

Arrow s Impossibility Theorem

Algebra 2 Semester 1 Practice Final

8 THREE PHASE A.C. CIRCUITS

Transcription:

Outline Leture Effiient XPth Evlution XML n Dtses. Top-Down Evlution of simple pths. Noe Sets only: Core XPth. Bottom-Up Evlution of Core XPth. Polynomil Time Evlution of Full XPth Sestin Mneth NICTA n UNSW CSE@UNSW -- Semester, 00. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths Simple pths re of the form () //tg_/tg_/ /tg_n () //tg_/tg_/ /tg_{n-}/text() Selets ny noe whih is () lele tg_n () text noe n evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = is hil of noe lele tg_{n-} [strtelement( )] is hil of noe lele tg_{n-} is hil of noe lele tg_ Exmples //uthor/lst = selet ll lst nmes of uthors //strip/hrters/hrter/text() = selet ll hrter nmes from DilertML oument =Q[] Thus, p=p+= prtil mth. If element nme ws ifferent from, then p woul remin equl to ) (return selete noes in oument orer..). Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q /// =Q query mth position: p = query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] Push urrent mth position p for every strtelement (exept for the root noe) =Q[] p==length(q), thus, urrent noe is mth! Mrk it s mth/result push(p) p =

. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q /// =Q query mth position: p = query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] Push urrent mth position p for every strtelement (exept for the root noe) =Q[] p==length(q), thus, urrent noe is mth! Mrk it s mth/result push(p) p = Push urrent mth position for every strtelement (exept for the root noe) =Q[] p==length(q), thus, urrent noe is mth! Mrk it s mth/result push(p) p = fter losing enelement() we nee to e in position p! (to mth next-siling) Question Why is p set to? Wht if query ws ///?. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] =Q[] Thus, push(p) n p=p+= 0. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] p = pop()

. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] =Q[] Thus, push(p) n p=p+=. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] p==length(q), thus, urrent noe is mth! Mrk it s mth/result push(p) p = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] =Q[]. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] push() [enelement( )] p = pop() =

. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [enelement( )] p = pop() = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] push() [enelement( )] p = pop() = [enelement( )] p = pop() = [enelement( )] p = pop() = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] push() [enelement( )] p = pop() = 0. Top-Down Evlution of Simple Pths. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) evlute in one single pre-orer trversl (using stk) /// =Q query mth position: p = /// =Q query mth position: p = [enelement( )] p = pop() = [enelement( )] p = pop() = [enelement( )] p = pop() = [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] push() [enelement( )] p = pop() = [enelement( )] p = pop() = [enelement( )] p = pop() = [enelement( )] p = pop() = [strtelement( )] mth [strtelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] [enelement( )] [strtelement( )] [strtelement( )] push() [enelement( )] p = pop() = [strtelement( )] push() [enelement( )] p = pop() =. Top-Down Evlution of Simple Pths evlute in one single pre-orer trversl (using stk) /// =Q Liner time: O( #Noes ) = O( D ) Size of oument Even: Streming Algorithm! No nee to store the oument!! Cn evlute on SAX event strem. But, to print result sutrees we nee n output uffer

. Top-Down Evlution of Simple Pths evlute using one single pre-orer trversl! (using stk). Top-Down Evlution of Simple Pths evlute using one single pre-orer trversl! (using stk) ///// ///// NOT equl. p= Wht to o next? Postfix (ening) of wht we hve seen, is prefix (eginning) of the query!!. Top-Down Evlution of Simple Pths evlute using one single pre-orer trversl! (using stk). Top-Down Evlution of Simple Pths evlute using one single pre-orer trversl! (using stk) ///// ///// Jump to position for next noe! Jump to position for next noe! Postfix (ening) of wht we hve seen, is prefix (eginning) of the query!! Postfix (ening) of wht we hve seen, is prefix (eginning) of the query!! This is the Knuth-Morris-Prtt Algorithm! (KMP) On mth filure, query-position must e upte to longest prefix in Q tht is postfix of wht we hve seen! Liner time string mthing jump-k-tle : (preproessing) for eh position in Q n fil (ing symol), etermine jump-k-position ll xes. Core XPth Types Noe Sets Boolens ll xes. Core XPth Types Noe Sets Boolens ll noe tests (ut, here, we will simply tlk out element noes only) ll noe tests (ut, here, we will simply tlk out element noes only) filters with logil opertions: n, or, not filters with logil opertions: n, or, not E.g. //esennt::/hil::[ hil::/hil:: or not(following::*) ] E.g. //esennt::/hil::[ hil::/hil:: or not(following::*) ] Full XPth itionlly hs Noe set omprisons & opertions (e.g., =, ount) Orer funtions (first, lst, position) Numeril opertions (sum, +, -, *, iv, mo, roun, et.) n orresponing omprisons (=,!=, <, >, <=, >=) String opertions (ontins, strts-with, trnslte, string-length, et.) Thus in Core XPth Selet noes only epening on lels. No ounting. No vlues. 0

Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set represente s it-fiel 0 0 0 0 0 0 0 0 Noe Set represente s it-fiel 0 0 0 0 0 0 0 0 Axis Evlution Mps Noe Set to Noe Set Axis Evlution Mps Noe Set to Noe Set In o orer Forwr Axes: self hil esennt-or-self esennt following following-siling Bkwr Axes: prent nestor nestor-or-self preeing preeing-siling ttriute reverse o orer t most #Noes mny Nïve: Noe-Set = {,,, } xis( Noe-Set ) = xis() xis() xis() xis() time liner in #Noes time liner in #Noes time liner in #Noes time liner in #Noes O( #Noes #Noes ) =qurti time Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set represente s it-fiel 0 0 0 0 0 0 0 0 Noe Set represente s it-fiel 0 0 0 0 0 0 0 0 Axis Evlution Mps Noe Set to Noe Set Axis Evlution Mps Noe Set to Noe Set Forwr Axes: self hil esennt-or-self esennt following following-siling Cn e one for ANY xis in liner time wrt numer of noes if we hve onstnt time look-up for first-hil(noe), prent(noe) next-siling(noe), previous-siling(noe) (for liner time forwr xis evlution, enough to hve first-hil/next-siling.) Ie No noe is visite >one! Cn e one for ANY xis in liner time wrt numer of noes if we hve onstnt time look-up for first-hil(noe), prent(noe) next-siling(noe), previous-siling(noe) (for liner time forwr xis evlution, enough to hve first-hil/next-siling.) In o orer Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set represente s it-fiel 0 0 0 0 0 0 0 0 0 Noe Set 0 0 0 0 0 0 0 0 0 Axis Evlution Mps Noe Set to Noe Set prent 0 - Ie No noe is visite >one! e.g.: nestor( {,, } ) look-up prents, hek if we re in result set lrey.. Cn e one for ANY xis in liner time wrt numer of noes if we hve onstnt time look-up for first-hil(noe), prent(noe) next-siling(noe), previous-siling(noe) (for liner time forwr xis evlution, enough to hve first-hil/next-siling.) Ie No noe is visite >one! e.g.: nestor( {,, } ) look-up prents, hek if we re in result set lrey..

Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set 0 0 0 0 0 0 0 0 0 Noe Set 0 0 0 0 0 0 0 0 0 prent 0 - prent 0 - Ie No noe is visite >one! e.g.: nestor( {,, } ) Result Noe Set 0 0 0 0 0 0 0 0 0 0 0 Ie No noe is visite >one! e.g.: nestor( {,, } ) Result Noe Set 0 0 0 0 0 0 0 0 0 0 look-up prents, hek if we re in result set lrey.. After one prent look-up. look-up prents, hek if we re in result set lrey.. After prent look-ups. Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set 0 0 0 0 0 0 0 0 0 Noe Set 0 0 0 0 0 0 0 0 0 prent 0 - prent 0 - move to next noe in Noe Set Ie No noe is visite >one! e.g.: nestor( {,, } ) Result Noe Set 0 0 0 0 0 0 0 0 0 0 Ie No noe is visite >one! e.g.: nestor( {,, } ) Result Noe Set 0 0 0 0 0 0 0 0 0 look-up prents, hek if we re in result set lrey.. After prent look-ups. look-up prents, hek if we re in result set lrey.. After prent look-ups. 0 Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Noe Set 0 0 0 0 0 0 0 0 0 Noe Set 0 0 0 0 0 0 0 0 0 Ie No noe is visite >one! e.g.: nestor( {,, } ) lrey in result set prent 0 - Result Noe Set 0 0 0 0 0 0 0 0 0 move to next noe in Noe Set Ie No noe is visite >one! e.g.: nestor( {,, } ) lrey in result set prent 0 - Result Noe Set 0 0 0 0 0 0 0 0 0 No next noe in Noe Set Finishe! look-up prents, hek if we re in result set lrey.. After prent look-ups. look-up prents, hek if we re in result set lrey.. After prent look-ups. + result look-ups.

Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Similrly: For ll other xes! +kwr xes? Forwr-xes only: inry (top-own) tree enoing provies esy liner time evlution! Ie No noe is visite >one! e.g.: nestor( {,, } ) look-up prents, hek if we re in result set lrey.. Question o you see how this works for e.g., esennt xis? Rell: to ess prent / nestors on inry tree, keep ynmilly list of ll nestors. Result Noe Set 0 0 0 0 0 0 0 0 0 After prent look-ups. + result look-ups. Axis Evlution Axis = Noe Set (evlute reltive to ontext-noe) Question o you see how this works for e.g., esennt xis? esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) esennt( { noe_, noe_,, noe_k } ) = S repet{ pik noe N in S; (for N s esennts M in pre-orer) { if (not(m in result set)) (M to result set) else rek; } } Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) Noe Set 0 0 0 0 0 0 0 0 0 0 0 Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + This exmple omes from Georg Gottlo n Christoph Koh "XPth Query Proessing". Invite tutoril t DBPL 00 http://www.i.tuwien..t/reserh/xmlskfore/xpth-tutoril.ppt.gz f ns 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + Result Noe Set 0 0 0 0 0 0 0 0 0 0 f ns 0 Exmple Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) 0 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + Result Noe Set 0 0 0 0 0 0 0 0 f ns 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + Result Noe Set 0 0 0 0 0 0 0 0 f ns 0

Exmple Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) 0 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + Result Noe Set 0 0 0 0 0 0 f ns 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + Result Noe Set 0 0 0 0 0 0 f ns 0 0 Exmple Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) 0 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + {,, 0 } + Result Noe Set 0 0 0 f ns 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + {,, 0 } + Result Noe Set 0 0 0 f ns 0 Exmple Exmple esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) esennt( noe ) = (first-hil next-siling)* (first-hil( noe )) 0 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + {,, 0 } + { } Result Noe Set 0 0 f ns 0 esennt( { } ) = (f ns)*(first-hil( { } )) = (f ns)*( { } ) = { } + {, } + {, } + {,, 0 } + { } Result Noe Set 0 0 f ns 0

ll xes ll noe tests Core XPth (ut, here, we will simply tlk out element noes only) filters with logil opertions: n, or, not Types Noe Sets Boolens. Bottom-Up Evlution of Core XPth With respet to query-tree (prse tree) NOT with respet to oument tree!! E.g. //esennt::/hil::[ hil::/hil:: or not(following::*) ] (lgorithm f. simple pths is top-own wrt oument tree) For Core XPth we only nee Noe Set opertions!! xis( Set ) = Set ( Set, Set ) = Set ( Set, Set ) = Set -( Set, Set ) = Set l() = Set union of Set n Set intersetion of Set n Set everything in Set ut not in Set ll noes lele y. Bottom-Up Evlution of Core XPth //esennt::/hil::[ hil::/hil:: or not(following::*) ] Axis evlution: O( #Noes ) = O( D ) Noe Set opertion: O( D ) Size of the Doument Core XPth query Q n e evlute in time O( Q D ) liner time! Size of the Query (= #steps) : : : : : : : : : Doument eomes ( esennt( {root} ), l() ) l() = {,, } l() = {,, } l() = {, } l() = { } xis ontext-noes noe test For Core XPth we only nee Noe Set opertions!! use for or s xis( Set ) = Set ( Set, Set ) = Set union of Set n Set use for not s ( Set, Set ) = Set intersetion of Set n Set -( Set, Set ) = Set everything in Set ut not in Set l() = Set ll noes lele y for noe tests for everything else (steps, filters) For Core XPth we only nee Noe Set opertions!! use for or s xis( Set ) = Set ( Set, Set ) = Set union of Set n Set use for not s ( Set, Set ) = Set intersetion of Set n Set -( Set, Set ) = Set everything in Set ut not in Set l() = Set ll noes lele y for noe tests for everything else (steps, filters) //esennt::/hil::[ hil::/hil:: or not(following::*) ] //esennt::/hil::[ hil::/hil:: or not(following::*) ] : : : : : : : eomes ( esennt( {root} ), l() ) = {,, } : : : : : : : eomes xis ( hil( ontext-noes ( esennt( {root} ), l() ) = {,, } ), l()) = noe test ( {,, }, {,, }) = {,, } : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } For Core XPth we only nee Noe Set opertions!! use for or s xis( Set ) = Set hil l() ( Set, Set ) = Set union of Set n Set use for not s ( Set, Set ) = Set intersetion of Set n Set -( Set, Set ) = Set everything in Set ut not in Set l() = Set ll noes lele y esennt l() for everything else (steps, filters) for noe tests { root } 0 0

//esennt::/hil::[ hil::/hil:: or not(following::*) ] : : : : = {,, } interset with noes x suh tht y: hil(x,y) n y l() n z: hil(y,z) n z l() *// //esennt::/hil::[ hil::/hil:: or not(following::*) ] : : : : = {,, } interset with noes x suh tht y: hil(x,y) n y l() n z: hil(y,z) n z l() *// : : : Bottom-Up (prse right-rnhing ) : : : Bottom-Up (prse right-rnhing ) : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } Cnites for z: l() For y: prent(l()) n lele = ( l(), prent(l()) ) For x: prent( ) : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } Cnites for z: l() For y: prent(l()) n lele = ( l(), prent(l()) ) For x: prent( ) hil l() prent hil l() prent esennt l() l() prent { root } { } l() { } esennt l() l() prent { root } { } l() //esennt::/hil::[ hil::/hil:: or not(following::*) ] //esennt::/hil::[ hil::/hil:: or not(following::*) ] : : : : = {,, } interset with noes x suh tht y: hil(x,y) n y l() n z: hil(y,z) n z l() *// : : : : = {,, } interset with noes x suh tht y: hil(x,y) n y l() n z: hil(y,z) n z l() *// : : : Bottom-Up (prse right-rnhing ) : : : Bottom-Up (prse right-rnhing ) : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } Cnites for z: l() For y: prent(l()) n lele = ( l(), prent(l()) ) For x: prent( ) : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } Cnites for z: l() For y: prent(l()) n lele = ( l(), prent(l()) ) For x: prent( ) = { } hil l() prent {, } { } esennt l() l() prent { } { root } l() { } hil l() prent { } {, } { } esennt l() l() prent { } { root } l() //esennt::/hil::[ hil::/hil:: or not(following::*) ] = {,, } : noes x suh tht */following::* interset not( y: following(x,y)) : : : with x : : : : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } om = {,, } Bottom-Up (prse right-rnhing ) Cnites for x: -( om, preeing( om ) ) = -( om, {,, }) = {,, } { } hil l() prent { } om {, } { } esennt l() l() prent { } { root } l() - {,, } preeing om //esennt::/hil::[ hil::/hil:: or not(following::*) ] = {,, } : interset eomes union! : : : with : : : : : Doument l() = {,, } l() = {,, } l() = {, } l() = { } om = {,, } {,,, } { } hil l() prent - {,, } { } om preeing {, } { } esennt l() l() prent om { } { root } l()

//esennt::/hil::[ hil::/hil:: or not(following::*) ] //esennt::/hil::[ hil::/hil:: or not(following::*) ] = {,, } : interset : : : with : : : eomes union! : : : : : : : BU Core XPth Algorithm: () Trnslte query (prse tree) into the noe-set-opertions tree elow () Evlute noe-set-ops tree. : : Doument {, } {,, } { } hil l() prent { } {, } { } esennt l() l() prent { } { root } l() {,,, } - {,, } om preeing om : : Doument {, } {,, } { } hil l() prent { } {, } { } esennt l() l() prent { } { root } l() {,,, } - {,, } om preeing om From Georg Gottlo n Christoph Koh "XPth Query Proessing". Invite tutoril t DBPL 00 http://www.i.tuwien..t/reserh/xmlskfore/xpth-tutoril.ppt.gz IE (ntive oe, Winows) Qurti-time evlution (oument size numer of noes) Core Xpth query (elow, size. Size in experiment: 0) //[nestor:://[nestor:://[nestor:://]]] Compre this to the top-own lgorithm for simple queries ///// BU Core XPth Algorithm: () Trnslte query (prse tree) into the noe-set-opertions tree elow () Evlute noe-set-ops tree. Stremle! :, : hil l() : : :,,, : hil l() > set opertions,, (ost pprox D ), hil l() vs -,, D ( look-up esennt l() + hil-ess + stk/int-upte ) { root } 0 Compre this to the top-own lgorithm for simple queries ///// Question BU Core XPth Algorithm: () Trnslte query (prse tree) into the noe-set-opertions tree elow () Evlute noe-set-ops tree. Stremle!. Polynomil Time Evlution of Full XPth All following slies re tken from Georg Gottlo n Christoph Koh "XPth Query Proessing". Invite tutoril t DBPL 00 http://www.i.tuwien..t/reserh/xmlskfore/xpth-tutoril.ppt.gz Cn you exten the top-own look-up lgorithm from simple queries (//// ) to ll Core XPth queries? How ig re look-up tles (if you wnt to hve one look-up per noe..)? Muh fster thn noe-set se lgorithm? > set opertions (ost pprox D ) vs D ( look-up + hil-ess + stk/int-upte )

Contexts XPth expressions re evlute w.r.t. Contexts ontext: <x, k, n> noe position size These vlues speify urrent sitution in whih query or suquery shoul e evlute. Determine y preeing XSL or Xpth omputtions. Previously ompute noe-set {n,n,n,n } Exmple of n Xpth query not in Core XPth Smple oument D: Smple query Q: <> </> </> </> </> </> hil::/following::*[position() > ] Continution of omputtion <n,,> This is the ontext informtion use for the further query evlution Strting t n Exmple of n Xpth query not in Core XPth Smple oument D: Smple query Q: <> </> </> </> </> </> hil::/following::*[position() > ] <,,> <,,> result noe-sets S evlute for eh x S, w.r.t ontext of x in S Exmple: Forml Semntis of Xpth Reltionl Opertors St. Semntis of Lotion Pths First forml semntis of relevnt frgment of XPth: Phil Wler

Context-vlue Tles (CVT) Four types of vlues (nset, num, str, ool) Define for eh XPth expression e The CVT of e is reltion R C (nset num str ool) Prse Tree of the Query Query: hil::/following::*[position()!= lst() n self::] N : hil::/n N : following::*[n ] Query Tree: N : N n N : N!= N : oolen(n ) N : position() N : lst() N : self:: 0 <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : N!= N N : position() N : lst() N N : N!= N N : position() N : lst() N (In ft, this is only relevnt suset of the full tles.) <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : N!= N N : position() N : lst() N (In ft, this is only relevnt suset of the full tles.) N : N!= N N : position() N : lst() N

<> </> </> </> </></> <> </> </> </> </></> N N N N N N N : N!= N N : N!= N N : position() N : lst() N N : position() N : lst() N <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : N!= N N : N!= N N : position() N : lst() N N : position() N : lst() N <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : N!= N N : N!= N N : position() N : lst() N N : position() N : lst() N 0

<> </> </> </> </></> <> </> </> </> </></> N N N N N N N : oolen(n ) N : oolen(n ) N N N : self:: N N N : self:: <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : oolen(n ) N : oolen(n ) N N N : self:: N N N : self:: <> </> </> </> </></> <> </> </> </> </></> N N N N N N N : oolen(n ) N : oolen(n ) N N N : self:: N N N : self::

<> </> </> </> </></> <> </> </> </> </></> N N N N N N N : oolen(n ) N : oolen(n ) N N N : self:: N N N : self:: <> </> </> </> </></> <> </> </> </> </></> N N N N N : N n N : N n N : N!= N : oolen(n ) N : N!= N : oolen(n ) N N N N N N 00 <> </> </> </> </></> <> </> </> </> </></> N N N N N : N n N : N n N : N!= N : oolen(n ) N : N!= N : oolen(n ) N N N N N N 0 0

<> </> </> </> </></> <> </> </> </> </></> N N N N N : N n N : N n N : N!= N : oolen(n ) N : N!= N : oolen(n ) N N N N N N 0 0 <> </> </> </> </></> <> </> </> </> </></> N N : hil::/n N N : following::*[n ] N : N n N : N n N : N!= N : oolen(n ) N N N N N N N 0 0 <> </> </> </> </></> <> </> </> </> </></> N : hil::/n N : hil::/n N : following::*[n ] N : following::*[n ] N : N n N : N n N N N N N N N N 0 0

<> </> </> </> </></> <> </> </> </> </></> N : hil::/n N : following::*[n ] N : hil::/n N : following::*[n ] N : N n N : N n N N N N N N N N 0 0 <> </> </> </> </></> <> </> </> </> </></> N : hil::/n N : hil::/n N : following::*[n ] N : following::*[n ] N : N n N : N n N N N N N N N N <> </> </> </> </></> <> </> </> </> </></> N : hil::/n N : hil::/n N : following::*[n ] N : following::*[n ] N : N n N : N n N N N N N N N N

if then Context-Vlue Tle Priniple CVT for eh opertion Op( e,..., e n ) n e ompute in polynomil time given the CVTs for su-expressions e,...,e n CVT of overll query n e ompute (ottomup) in polynomil time. Time n Spe Bouns Bottom-up evlution se on CVT: Time O( t * query ), Spe O( t * query ). Spe oun (n numer of noes in input oument.): Contexts re t most triples: t most n ontexts. Sizes of vlues: Noe sets: t most O(n) Strings, numers: t most O( t * query ) (iterte ontention of strings, multiplition of numers) Eh CVT is of size ( t * query ). Nee to ompute CVT for eh query noe n eh input noe ( t * query ) ( t * query ) Time oun: most expensive omputtion is O(n ) Reltionl opertion = on noe sets (e.g. ///[//e/f/g = h/i//j]) Effiieny of the PTIME Algorithm Alterntive Context Representtion Time Complexity O( D * Q ) Spe Complexity O( D * Q ) In prtie, most queries run in qurti time Contexts represente s ( previous ontext noe, urrent ontext noe ) rther thn ( ontext noe, position, size ). Nee to reompute position n size on emn. ///[position() + = size()] 0: This is for min-memory implementtions. Apttion to seonry storge lgorithms with PTIME omplexity is esy (ut with worse ouns thn the ones given ove). hil:: { (,), (,), (,), (,), (,) } hil::[position()+=size()] { (,), (,) } : : : : : : : Complexity lowere to time O( t * query ), spe O( t * query ). Context Simplifition Tehnique Liner Spe Frgment. Only mterilize relevnt ontext.. Core Xpth evlution lgorithm for outermost n innermost pths //////[ ]/e[ (//)].. Treting position n size in loop. Beuse of tree shpe of query, loops never hve to e neste. Wler Frgment [Wler, ]: Core Xpth + position(), lst(), n rithmetis. Evlution in qurti time n liner spe. (n,p,s) (n,p,s) ///[position() * = lst() n /[position()* = lst()]]//e esennt:: (n) /hil::[ ] position() = ount( ) (n,p, s) - loop hil::[ ] Compute noe set for whih hil::[ ] is true (n,p, s) - loop position() + = lst() (n) (n) (n) (n) For x in [[//]] ompute ontexts (y,p,n) in x.[[]] Compute Y = { y (y,p,n) x.[[]] n p*=n }. Similrly, ompute Z = { z z.[[ [position()* = lst()] ]] is true}. Compute X = { x z Z, x z.[[ hil:: ]] - } in liner time. Result is { w v X Y, w v.[[esennt::e]] }. 0 0

Summry Full XPth Bottom-up lgorithm se on CVT Time O( t * query ), spe O( t * query ). Top-own evlution Time O( t * query ), spe O( t * query ). Context-reution tehnique Time O( t * query ), spe O( t * query ). END Leture Wler frgment Time O( t * query ), spe O( t * query ). Core Xpth Time n spe O( t * query ).