1 / 36

Appendix: how the ENVS and QRES stacks work ( M0 example)

Appendix: how the ENVS and QRES stacks work ( M0 example). Presentation prepared for OMG Object Database Technology Working Group OMG TECHNICAL MEETING, Anaheim, CA USA September 25-29,  2006 by Prof . Kazimierz Subieta Polish-Japanese Institute of Information Technology, Warsaw, Poland

Download Presentation

Appendix: how the ENVS and QRES stacks work ( M0 example)

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. Appendix: how the ENVS and QRES stacks work (M0 example) Presentation prepared for OMG Object Database Technology Working Group OMG TECHNICAL MEETING, Anaheim, CA USASeptember 25-29,  2006 by Prof. Kazimierz Subieta Polish-Japanese Institute of Information Technology, Warsaw, Poland subieta@pjwstk.edu.pl http://www.ipipan.waw.pl/~subieta SBA/SBQL pages:http://www.sbql.pl

  2. Query addressing a tiny database • Query: For each department get its reference and the average sal of its employees. • SBQL: Deptjoinavg((employs.Emp).sal) • Tiny database: • Expected result: bag{ struct{i17, 2500}, struct{i22, 1450} }

  3. Query syntax tree and execution scenario Deptjoin avg( ( employs . Emp ) . sal ) join Dept avg 2nd dot . 1st dot . sal employs Emp 1stemploys 1stEmp 1stDept 2ndemploys 2ndEmp 2ndDept 3rdemploys 3rdEmp avg join 1st dot 2nd dot

  4. 0 Deptjoinavg((employs.Emp). sal) Start Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) empty ENVS QRES

  5. 1 Deptjoin avg( ( employs . Emp ) . sal ) After binding Dept Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  6. 2 Deptjoin avg( ( employs . Emp ) . sal ) join starts 1st loop of the iteration over top of QRES dname(i18) loc(i19) loc(i20) employs(i21) nested Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  7. 3 Deptjoin avg( ( employs . Emp ) . sal ) After binding employs dname(i18) loc(i19) loc(i20) employs(i21) i21 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  8. 4 Deptjoin avg( ( employs . Emp ) . sal ) dot starts iteration on top of QRES nested Emp(i1) dname(i18) loc(i19) loc(i20) employs(i21) i21 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  9. 5 Deptjoin avg( ( employs . Emp ) . sal ) After binding Emp Emp(i1) dname(i18) loc(i19) loc(i20) employs(i21) i1 i21 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  10. 6 Deptjoin avg( ( employs . Emp ) . sal ) Closing the iteration by the first dot dname(i18) loc(i19) loc(i20) employs(i21) i1 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  11. 7 Deptjoin avg( ( employs . Emp ) . sal ) Second dot starts iteration over top of QRES name(i2) sal(i3) worksIn(i4) nested dname(i18) loc(i19) loc(i20) employs(i21) i1 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  12. 8 Deptjoin avg( ( employs . Emp ) . sal ) After binding sal name(i2) sal(i3) worksIn(i4) dname(i18) loc(i19) loc(i20) employs(i21) i3 i1 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  13. 9 Deptjoin avg( ( employs . Emp ) . sal ) Closing the iteration by the second dot dname(i18) loc(i19) loc(i20) employs(i21) i3 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  14. 10 Deptjoin avg( ( employs . Emp ) . sal ) After performing avg on top of QRES dname(i18) loc(i19) loc(i20) employs(i21) 2500 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  15. 11 Deptjoin avg( ( employs . Emp ) . sal ) join forms the first partial result Partial result of join: struct{ i17, 2500 } dname(i18) loc(i19) loc(i20) employs(i21) 2500 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  16. 12 Deptjoin avg( ( employs . Emp ) . sal ) After ending the 1st loop by join Partial result of join: struct{ i17, 2500 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  17. 13 Deptjoin avg( ( employs . Emp ) . sal ) join starts 2nd loop of the iteration over top of QRES Partial result of join: struct{ i17, 2500 } dname(i23) loc(i24) employs(i25) employs(i26) nested Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  18. 14 Deptjoin avg( ( employs . Emp ) . sal ) After binding employs Partial result of join: struct{ i17, 2500 } dname(i23) loc(i24) employs(i25) employs(i26) bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  19. 15 Deptjoin avg( ( employs . Emp ) . sal ) First dot starts 1st loop of iteration on top of QRES Partial result of join: struct{ i17, 2500 } Emp(i5) nested dname(i23) loc(i24) employs(i25) employs(i26) bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  20. 16 Deptjoin avg( ( employs . Emp ) . sal ) After binding Emp Partial result of join: struct{ i17, 2500 } Emp(i5) dname(i23) loc(i24) employs(i25) employs(i26) i5 bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  21. 17 Deptjoin avg( ( employs . Emp ) . sal ) Forming 1st partial result of the first dot Partial result of join: struct{ i17, 2500 } Partial result of dot: i5 dname(i23) loc(i24) employs(i25) employs(i26) bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  22. 18 Deptjoin avg( ( employs . Emp ) . sal ) Firstdot starts 2nd loop of iteration on top of QRES Partial result of join: struct{ i17, 2500 } Partial result of dot: i5 Emp(i9) nested dname(i23) loc(i24) employs(i25) employs(i26) bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  23. 19 Deptjoin avg( ( employs . Emp ) . sal ) After binding Emp Partial result of join: struct{ i17, 2500 } Partial result of dot: i5 Emp(i9) dname(i23) loc(i24) employs(i25) employs(i26) i9 bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  24. 20 Deptjoin avg( ( employs . Emp ) . sal ) Forming 2nd partial result of the first dot Partial result of join: struct{ i17, 2500 } i9 Partial results of dot: i5 dname(i23) loc(i24) employs(i25) employs(i26) bag{ i25 , i26 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  25. 21 Deptjoin avg( ( employs . Emp ) . sal ) Closing iteration by the first dot, forming its result Partial result of join: struct{ i17, 2500 } dname(i23) loc(i24) employs(i25) employs(i26) bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  26. 22 Deptjoin avg( ( employs . Emp ) . sal ) Second dot starts 1st loop of iteration on top of QRES Partial result of join: struct{ i17, 2500 } name(i6) sal(i7) worksIn(i8) nested dname(i23) loc(i24) employs(i25) employs(i26) bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  27. 23 Deptjoin avg( ( employs . Emp ) . sal ) After binding sal Partial result of join: struct{ i17, 2500 } name(i6) sal(i7) worksIn(i8) dname(i23) loc(i24) employs(i25) employs(i26) i7 bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  28. 24 Deptjoin avg( ( employs . Emp ) . sal ) Forming 1st partial result of the second dot Partial result of join: struct{ i17, 2500 } Partial result of dot: i7 dname(i23) loc(i24) employs(i25) employs(i26) bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  29. 25 Deptjoin avg( ( employs . Emp ) . sal ) Second dot starts 2nd loop of iteration on top of QRES Partial result of join: struct{ i17, 2500 } Partial result of dot: i7 name(i10) sal(i11) address(i12) worksIn(i16) nested dname(i23) loc(i24) employs(i25) employs(i26) bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  30. 26 Deptjoin avg( ( employs . Emp ) . sal ) After binding sal Partial result of join: struct{ i17, 2500 } Partial result of dot: i7 name(i10) sal(i11) address(i12) worksIn(i16) dname(i23) loc(i24) employs(i25) employs(i26) i11 bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  31. 27 Deptjoin avg( ( employs . Emp ) . sal ) Forming 2nd partial result of the second dot Partial result of join: struct{ i17, 2500 } i11 Partial result of dot: i7 dname(i23) loc(i24) employs(i25) employs(i26) bag{ i5 , i9 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  32. 28 Deptjoin avg( ( employs . Emp ) . sal ) Closing iteration by the second dot, forming its result Partial result of join: struct{ i17, 2500 } dname(i23) loc(i24) employs(i25) employs(i26) bag{ i7 , i11 } Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  33. 29 Deptjoin avg( ( employs . Emp ) . sal ) After performing avg on top of QRES Partial result of join: struct{ i17, 2500 } dname(i23) loc(i24) employs(i25) employs(i26) 1450 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  34. 30 Deptjoin avg( ( employs . Emp ) . sal ) join forms 2nd partial result Partial results of join: struct{ i17, 2500 } struct{ i22, 1450 } dname(i23) loc(i24) employs(i25) employs(i26) 1450 Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ i17 , i22 } ENVS QRES

  35. 31 Deptjoin avg( ( employs . Emp ) . sal ) Closing the iteration by join, forming the final result Emp(i1) Emp(i5) Emp(i9) Dept(i17) Dept(i22) bag{ struct{ i17, 2500}, struct{ i22 , 1450} } ENVS QRES

  36. In closing … • Please note that this evaluation scenario concerns the formal semantics executed by the abstract machine. • Our goal is clear, universal and free of ambiguities semantic specification rather than performance. • In real implementation there are many obvious optimizations. • The evaluation process is also the subject of many sophisticated optimizations (rewriting, indices, caching,…) . • The entire process is executed in the main memory, hence the computations are not critical. • Critical computations concern the access to external storage and network, and avoiding unnecessary (redundant) computations. • This is the subject of major SBA optimization methods.

More Related