1 / 40

OrientX 系统开发报告

OrientX 系统开发报告. XML Group. 大纲. OrientX3.5 的主要特征 问题分析 Transform—— 基于代数的实现 数据抽取 ——Holistic Twig 实现 总结. V3.5 的主要特征. Support XQuery/Update (transform) A set of programming API Query Optimization Holistic Twig Query enabled Usable index management. 大纲. OrientX3.5 的主要特征 问题分析

harley
Download Presentation

OrientX 系统开发报告

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OrientX系统开发报告 XML Group

  2. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • 数据抽取——Holistic Twig实现 • 总结

  3. V3.5的主要特征 • Support XQuery/Update (transform) • A set of programming API • Query Optimization • Holistic Twig Query enabled • Usable index management

  4. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • 数据抽取——Holistic Twig实现 • 总结

  5. 问题1 • 如何实现Transform查询? • 查询编译 • Lex、Yacc • 查询处理 • 修改XML代数 • 添加Transform操作符

  6. 问题2 bib.xml

  7. 问题2 <bib> {for $b in doc("bib.xml")/bib/book let $a := $b/author where $b//publisher/text() = "Addison-Wesley" and $b/@year > 1991 return <book year="{ $b/@year }"> { $b/author} </book>} </bib> 结果构造: 内存中的中间结果 结果构造: 内存中的中间结果 数据抽取: 访问磁盘的操作 数据抽取的效率很大程度上决定了代数系统的效率

  8. 问题2—数据抽取效率 • 数据抽取的方法[1]有: • Navigation:对文档树进行遍历,找到满足pattern tree 的实例树;效率低下。 • Structure Join:利用对XML 数据的编码和Tag Index,快速地找到满足祖先后代关系的结点。 • Holistic Twig Join:整体求解 OrientX采用策略 [1] 孟小峰,罗道锋,蒋瑜,王宇,OreintXA:一种有效的XQuery查询代数,软件学报,卷15(11),1648-1660,2004,11

  9. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • 数据抽取——Holistic Twig实现 • 总结

  10. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • Transform操作概述 • 查询编译器对transform的支持 • Transform的代数计划生成 • Transform的物理操作符的算法实现 • 数据抽取——Holistic Twig实现 • 总结

  11. Transform的语法定义 • <transformExpr>::= ‘copy’ $var ‘:=‘ <Expr> (‘,’ $var ‘:=’ <Expr>)* ‘modify’ <Expr> ‘return’ <Expr> • Modify操作的Expr是由update组成的表达式(insert\delete\rename\replace) • Transform更新操作与原有的四个更新操作的区别是并不改变数据库的状态

  12. Insert $node into $u Construct $node Extract$u=doc(“users.xml”)//users <user_tuple> <userid>U07</userid> <name>Tom</name> </user_tuple> Construct $u Insert nodes <user_tuple> <userid>U07</userid> <name>Tom</name> </user_tuple> Into doc("users.xml")/users Copy $nu:= doc("users.xml")/users Modify Insert nodes <user_tuple> <userid>U07</userid> <name>Tom</name> </user_tuple> Into $nu Return $nu Insert $node into $u Construct $node Copy$nu:=$u <user_tuple> <userid>U07</userid> <name>Tom</name> </user_tuple> Extract$u=doc(“users.xml”)//users

  13. Transform查询引入新的代数操作 • Copy:𝜅P1,NL(X) • Modify中所含的更新操作(与update操作有区别-modify只对内存中的数据更新): • Modify_insert: 𝜏m P1,P2,IS(X1,X2) • Modify_delete: 𝜓m P, NL(X) • Modify_rename: 𝜌m P, RS(X) • Modify_replace: 𝜇m P1,P2,RS,RF(X1,X2)

  14. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • Transform操作概述 • 查询编译器对transform的支持 • Transform的代数计划生成 • Transform的物理操作符的算法实现 • 数据抽取——Holistic Twig实现 • 总结

  15. transform查询解析 • 在lex词法解析器中增加对copy、modify的支持 • 该写yacc,扩展语法树

  16. 词法解析 • Transform语句的解析 • Lex

  17. 语法解析 • Transform语句的解析 • Yacc • 需要注意的是,在语法树中对Copy后的那个结点加一个标识,标志这棵语法树上的所有点都无需写回内存

  18. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • Transform操作概述 • 查询编译器对transform的支持 • Transform的代数计划生成 • Transform的物理操作符的算法实现 • 数据抽取——Holistic Twig实现 • 总结

  19. XQuery syntax tree PatternTreeGenerator PatternTree List & Predicate List AlgebraTreeGenerator AlgebraTree Transform的代数查询计划生成 XQueryParser Excutor

  20. ProcessAsXQuery(PT, Expr1) $var加入VARIALES,指向PT.targetNode New copy(PT, PT.targetNode) AddToAlgebraPlan(copy) Process(modify(Expr2)) ProcessasXQuery(NULL, Expr3) Transform的代数查询计划生成算法 <transformExpr>::= ‘copy’ $var ‘:=‘<Expr1>‘modify’<Expr2> ‘return’ <Expr3>

  21. 实例 Let $doc := doc(“bib.xml”) return copy $ndoc :=$doc modify delete $ndoc/book[publisher = “Addison- Wesley”]/price return $ndoc/book[author = “Rose”]

  22. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • Transform操作概述 • 查询编译器对transform的支持 • Transform的代数计划生成 • Transform的物理操作符的算法实现 • 数据抽取——Holistic Twig实现 • 总结

  23. Copy操作符的实现 • Copy:𝜅P1,NL(X) • 从PatternTree List中取出P1, • begin: read(x)//x是X的一个实例树 If( Match(x,P1)) return(x’) // x’由NL中的结点拷贝构成 else goto step2 end:直到将X中的实例比较完 • 将结果x’传给下一个操作符

  24. M odify操作符的实现 • Modify中包含四个更新操作 Modify_insert、Modify_delete、Modify_rename、Modify_replace • 与原来的更新操作不同,只对copy操作的结果进行更新,并不修改数据库

  25. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • 数据抽取——Holistic Twig实现 • 三种比较 • 总结

  26. 大纲 • Twig 查询 • 导航式 • 二元结构连接 • TwigStack

  27. ... allauthors ( 1 , 5 : 60 , 2 ) author 1 author 2 author 3 ( 1 , 6 : 20 , 3 ) ln 3 fn 1 ln 2 fn 2 fn 3 ln 1 ( 1 , 7 : 9 , 4 ) doe 2 jane 1 poe doe 1 jane 2 john ( 1 , 46 , 5 ) ( 1 , 8 , 5 ) ( 1 , 11 , 5 ) ( 1 , 43 , 5 ) ( 1 , 26 , 5 ) Twig 查询 查询: //author[fn=‘jane’ AND ln=‘doe’] author fn ln jane doe Twig pattern

  28. 导航 • 特点: • 容易实现 • 效率低下 a1 a b1 c1 b2 b3 d d1 d2 e1 f1 Query Document 导航式地匹配Twig Pattern上的每一结点:从twig pattern根节点开始,深度优先遍历整个文档

  29. a a b a b c b d c d a1 b1 c1 b2 b3 d1 d2 e1 f1 二元结构连接 大量中间结果 1.将Twig Pattern分解成二元结构关系 2.匹配二元关系 3.缝接 2 3 2 1

  30. ... allauthors ( 1 , 5 : 60 , 2 ) author 1 author 2 author 3 ( 1 , 6 : 20 , 3 ) ln 3 fn 1 ln 2 fn 2 fn 3 ln 1 ( 1 , 7 : 9 , 4 ) doe 2 jane 1 poe doe 1 jane 2 john ( 1 , 46 , 5 ) ( 1 , 8 , 5 ) ( 1 , 11 , 5 ) ( 1 , 43 , 5 ) ( 1 , 26 , 5 ) TwigStack • 区间编码 • 每个结点看成一个流,并且按star_pos排序 Streams Ta: a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj: j1, j2 Td: d1, d2

  31. 栈和游标 TwigStack中的栈和游标

  32. getNext函数从流中获取满足SE的结点 • 根据Max-Child 结点跳过不可能是解的元素 • 当当前结点与所有子查询结点构成匹配时,返回当前结点,否则返回Min-Child 递归调用直到查询树的叶子结点 TwigStack getNext getNext … • 主函数产生局部的单Path路径 • 最后 merge 所有单Path路径

  33. allauthors (1,3:60,2) author1 author2 author3 (1,4:11,3) (1,12:19,3) (1,20:27,3) fn1 ln1 fn2 ln2 fn3 ln3 (1,5:7,4) (1,8:10,4) (1,13:15,4) (1,16:18,4) (1,21:23,4) (1,24:26,4) jane1 poe john doe1 jane2 doe2 (1,6,5) (1,9,5) (1,14,5) (1,17,5) (1,22,5) (1,25,5) author fn ln jane doe Query Document Streams Ta : a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj: j1, j2 Td : d1, d2 Stacks

  34. allauthors (1,5:60,2) author1 author2 author3 (1,4:11,3) (1,12:19,3) (1,20:27,3) fn1 ln1 fn2 ln2 fn3 ln3 (1,5:7,4) (1,8:10,4) (1,13:15,4) (1,16:18,4) (1,21:23,4) (1,24:26,4) jane1 poe john doe1 jane2 doe2 (1,6,5) (1,9,5) (1,14,5) (1,17,5) (1,22,5) (1,25,5) author fn ln jane doe Query Document Streams Ta : a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj : j1, j2 Td : d1, d2 Stacks

  35. allauthors (1,5:60,2) author1 author2 author3 (1,4:11,3) (1,12:19,3) (1,20:27,3) fn1 ln1 fn2 ln2 fn3 ln3 (1,5:7,4) (1,8:10,4) (1,13:15,4) (1,16:18,4) (1,21:23,4) (1,24:26,4) jane1 poe john doe1 jane2 doe2 (1,6,5) (1,9,5) (1,14,5) (1,17,5) (1,22,5) (1,25,5) author fn ln jane doe Query Document Streams Ta : a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj : j1, j2 Td : d1, d2 Stacks

  36. allauthors (1,5:60,2) author1 author2 author3 (1,4:11,3) (1,12:19,3) (1,20:27,3) fn1 ln1 fn2 ln2 fn3 ln3 (1,5:7,4) (1,8:10,4) (1,13:15,4) (1,16:18,4) (1,21:23,4) (1,24:26,4) jane1 poe john doe1 jane2 doe2 (1,6,5) (1,9,5) (1,14,5) (1,17,5) (1,22,5) (1,25,5) author fn ln jane doe Query Document Streams Ta : a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj : j1, j2 Td : d1, d2 Stacks

  37. allauthors (1,5:60,2) author1 author2 author3 (1,4:11,3) (1,12:19,3) (1,20:27,3) fn1 ln1 fn2 ln2 fn3 ln3 (1,5:7,4) (1,8:10,4) (1,13:15,4) (1,16:18,4) (1,21:23,4) (1,24:26,4) jane1 poe john doe1 jane2 doe2 (1,6,5) (1,9,5) (1,14,5) (1,17,5) (1,22,5) (1,25,5) author fn ln jane doe Query Document Streams Ta : a1, a2, a3 Tfn: fn1, fn2, fn3 Tln: ln1, ln2, ln3 Tj: j1, j2 Td : d1, d2 Stacks Path1: a3-fn3-j2 Path2: a3-ln3-d2 d2 J2 ln3 fn3 a3 Merge (j2, fn3, d2, ln3, a3)

  38. 大纲 • OrientX3.5的主要特征 • 问题分析 • Transform——基于代数的实现 • 数据抽取——Holistic Twig实现 • 总结

  39. 总结 • Transform的实现 • Holistic Twig的实现 • 进展: • 发布: • 本月底

  40. Thanks!

More Related