view-based tree-language rewritings -...
TRANSCRIPT
![Page 1: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/1.jpg)
View-Based Tree-Language Rewritings
Laks Lakshmanan, Alex Thomo University of British Columbia, Canada
University of Victoria, Canada
![Page 2: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/2.jpg)
Importance of trees – XML
• Semi-structured textual formats are very popular.
<movie> <title>House of cards</title> <year>2013</year> <character> <name>Francis</name> <actor>Kevin Spacey</actor> </character> <character> <name>Claire</name> <actor>Robin Wright</actor> </character> </movie>
XML (Multi TB) success stories: 1. Elsevier
• Papers and books
2. JPMorgan Chase & Co • Stock research data
3. JetBlue Airways • Document management
Source: MarkLogic XML Impacting the Enterprise Tapping into the Power of XML: Five Success Stories
![Page 3: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/3.jpg)
Importance of trees – JSON
• Semi-structured textual formats are very popular.
"movie": { "title": "House of cards", "year": "2013", "character": [ { "name": "Francis", "actor": "Kevin Spacey" }, { "name": "Claire", "actor": "Robin Wright" } ] }
JSON (Multi TB) success stories: 1. CouchDB 2. MongoDB 3. Jaql and Hive JSON SerDe for
Hadoop Mantra: “Log first, ask questions later”
![Page 4: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/4.jpg)
Trees visually movie
title year character character
name actor
Francis Kevin Spacey
House of Cards 2013
name actor
Claire Robin Wright
![Page 5: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/5.jpg)
Another example
![Page 6: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/6.jpg)
Importance of views (example)
• Big database of movies in a super-tree, – each movie being a sub-tree
• Query asks for all the movie sub-trees with a MAC. – small minority; number about 50.
– Result materialized into a view.
• Tremendous help in answering new queries, e.g. – “find actors playing a MAC”.
– Rewrite into: “find actors playing a MAC in a movie having a MAC”
– answer it on the materialized view.
![Page 7: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/7.jpg)
Regular Expressions and Automata
• Automaton
00 ss
10 ss m
11 ss
21 ss c
3
ˆ
2 ss a
acm ˆ_*_*
• Return all movie actors A pattern
![Page 8: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/8.jpg)
Reverse
• Automaton
a
a ss ˆ
c
c
a ss
cc ss
m
m
c ss
mm ss
• Return all movie actors
acm ˆ_*_*
A pattern
![Page 9: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/9.jpg)
Bottom-up Tree Automata
• Automaton
c
c
a ssss **
cc ssss **
m
m
c ssss **
mm ssss **
• Return all movie actors
a
a ss ˆ
ss
acm ˆ_*_*
A pattern
![Page 10: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/10.jpg)
Run
![Page 11: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/11.jpg)
Bottom-up Tree Automata (II)
• Automaton
acm ˆ_*_*MAC
• Return all movie actors of MACs
c
c
aaaa sssssss *|* ˆˆ
cc ssss **
m
m
c ssss **
mm ssss **
a
a ss ˆ
ˆ ss
a
a ss A pattern
![Page 12: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/12.jpg)
Bottom-up Tree Automata (IV)
• Automaton
acmMAC
_*ˆ_*
• Return all movies having some MACs
c
c
aa sssss **
cc ssss **
m
m
c ssss ˆ
**
mm ssss **
ss
a
a ss A pattern
![Page 13: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/13.jpg)
Run
![Page 14: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/14.jpg)
Bottom-up Tree Automata (V)
• Regular tree languages (RTAs) – the sets of trees recognized by TAs. – closed under intersection and complement
• Deterministic TA
– For any tree t, there can be at most one accepting run of A on t.
– Power-wise, TA = DTA.
• Complement obtained from deterministic TA
• Intersection via a special construction preserves
determinism.
![Page 15: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/15.jpg)
Queries
• Queries are regular sets of trees over
ˆ
• Containment Lemma
2121 ansans implies QQQQ
![Page 16: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/16.jpg)
Star Operation
![Page 17: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/17.jpg)
Filled Star Operation
![Page 18: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/18.jpg)
Transformation for avoiding marker overlap
![Page 19: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/19.jpg)
Rewriting, and two sets Maximally contained rewriting:
The bad set:
The promising set:
Proposition.
![Page 20: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/20.jpg)
Example with chains
![Page 21: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/21.jpg)
Example with chains (II)
![Page 22: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/22.jpg)
Inverse of the star operation
Proposition.
Compute where J and J’ are RTQ
![Page 23: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/23.jpg)
Colored Alphabets
• Markers will be colors
– Blue for J
– Red for J’
![Page 24: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/24.jpg)
Colored Languages
set of all trees having one node blue
set of all trees having one node red
set of all trees having one node blue and another red as descendant of the blue node
set of all trees having all nodes black, except root which is red
set of all trees having all nodes black, except for the root which is blue and another node which is red.
![Page 25: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/25.jpg)
Colored Languages (II)
![Page 26: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/26.jpg)
Colored Languages (III)
over
same as p, but with blue nodes turned black
same as p, but with red nodes turned black
over
![Page 27: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/27.jpg)
Colored Languages (IV)
automaton for
Similarly:
![Page 28: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/28.jpg)
Rewriting Algorithm
Theorem.
Compute:
![Page 29: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/29.jpg)
Rewriting Algorithm (II)
![Page 30: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/30.jpg)
Complexity
• Proposition. can be computed in polynomial time.
• Theorem. The MCR of Q using V can be computed in exponential time.
• Theorem. Computing the MCR of Q using V is EXPTIME-hard.
![Page 31: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/31.jpg)
Final Notes
• Query automata formalism used is equivalent in power to MSO (golden standard)
– For specifying node-selecting queries.
– Colors correspond to Boolean markings • J. Niehren, L. Planque, J.-M. Talbot, and S. Tison. N-ary queries by
tree automata. DBPL, 2005
• XPath rewriting is NP-hard.
• XPath is a subclass of our formalism.
– Our automata-based algorithm can be used as well for rewriting XPath queries.
![Page 32: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/32.jpg)
K-ary queries
• Example: Find the 2-forests of actor tree pairs for actors who have played the same character together in some movie.
• Automaton
c
c
aa sssss ** ˆˆ
cc ssss **
m
m
c ssss **
mm ssss **
a
a ss ˆ
ˆ ss A pattern
![Page 33: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/33.jpg)
Run
![Page 34: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/34.jpg)
Why is rewriting K-ary queries challenging
• It has been shown that k-ary queries can be encoded by unary queries
– T. Schwentick. On diving in trees. In MFCS, 2000.
– Done by going through MSO formulas.
– Going from a k-ary query to an MSO encoding and then back to automata incurs non elementary complexity.
• Therefore we need a another algorithm for rewriting k-ary queries
– that doen’t go via MSO formulas
![Page 35: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/35.jpg)
Conclusions • Characterized view-based rewriting as solving a lang. equation
– Defined appropriate tree operators
• Defined colored languages – Gave automata constructions
• Computed rewriting as a series of operations on automata
• Characterized the complexity of computing rewriting – Tight lower bound provided
• Extended the results to k-ary queries – Common in XQuery
![Page 36: View-Based Tree-Language Rewritings - UVic.cawebhome.cs.uvic.ca/~thomo/papers/TreeLanguageRewritingsFoIKS2… · View-Based Tree-Language Rewritings Laks Lakshmanan, Alex Thomo University](https://reader034.vdocuments.mx/reader034/viewer/2022042212/5eb5671b0635807ea55b65c8/html5/thumbnails/36.jpg)
Thank You