1 / 76

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications. C. Faloutsos Spatial Access Methods - R-trees. General Overview. Relational model – SQL; db design Indexing; Q-opt;Transaction processing Advanced topics Distributed Databases RAID Authorization / Stat. DB

tarika
Télécharger la présentation

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications

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. Carnegie Mellon Univ.Dept. of Computer Science15-415 - Database Applications C. Faloutsos Spatial Access Methods - R-trees

  2. General Overview • Relational model – SQL; db design • Indexing; Q-opt;Transaction processing • Advanced topics • Distributed Databases • RAID • Authorization / Stat. DB • Spatial Access Methods (SAMs) • Multimedia Indexing 15-415 - C. Faloutsos

  3. SAMs - Detailed outline • spatial access methods • problem dfn • z-ordering • R-trees 15-415 - C. Faloutsos

  4. SAMs - more detailed outline • R-trees • main idea; file structure • (algorithms: insertion/split) • (deletion) • (search: range, nn, spatial joins) • variations (packed; hilbert;...) 15-415 - C. Faloutsos

  5. Reminder: problem • Given a collection of geometric objects (points, lines, polygons, ...) • organize them on disk, to answer spatial queries (range, nn, etc) 15-415 - C. Faloutsos

  6. R-trees z-ordering: cuts regions to pieces -> dup. elim. how could we avoid that? Idea: Minimum Bounding Rectangles 15-415 - C. Faloutsos

  7. R-trees [Guttman 84] Main idea: allow parents to overlap! => guaranteed 50% utilization => easier insertion/split algorithms. (only deal with Minimum Bounding Rectangles - MBRs) 15-415 - C. Faloutsos

  8. R-trees • eg., w/ fanout 4: group nearby rectangles to parent MBRs; each group -> disk page I C A G H F B J E D 15-415 - C. Faloutsos

  9. A H D F G B E I C J R-trees • eg., w/ fanout 4: P1 P3 I C A G H F B J E P4 P2 D 15-415 - C. Faloutsos

  10. P1 H A D F P2 G B E I P3 C J P4 R-trees • eg., w/ fanout 4: P1 P3 I C A G H F B J E P4 P2 D 15-415 - C. Faloutsos

  11. P1 A P2 B P3 C P4 R-trees - format of nodes • {(MBR; obj-ptr)} for leaf nodes x-low; x-high y-low; y-high ... obj ptr ... 15-415 - C. Faloutsos

  12. P1 A P2 B P3 C P4 x-low; x-high y-low; y-high ... node ptr ... R-trees - format of nodes • {(MBR; node-ptr)} for non-leaf nodes 15-415 - C. Faloutsos

  13. P1 A H D F P2 G B E I P3 C J P4 R-trees - range search? P1 P3 I C A G H F B J E P4 P2 D 15-415 - C. Faloutsos

  14. P1 A H D F P2 G B E I P3 C J P4 R-trees - range search? P1 P3 I C A G H F B J E P4 P2 D 15-415 - C. Faloutsos

  15. R-trees - range search Observations: • every parent node completely covers its ‘children’ • a child MBR may be covered by more than one parent - it is stored under ONLY ONE of them. (ie., no need for dup. elim.) 15-415 - C. Faloutsos

  16. R-trees - range search Observations - cont’d • a point query may follow multiple branches. • everything works for any dimensionality 15-415 - C. Faloutsos

  17. SAMs - more detailed outline • R-trees • main idea; file structure • algorithms: insertion/split • deletion • search: range, nn, spatial joins • performance analysis • variations (packed; hilbert;...) 15-415 - C. Faloutsos

  18. P1 A H D F P2 G B E I P3 C J P4 R-trees - insertion • eg., rectangle ‘X’ P1 P3 I C A G H F B X J E P4 P2 D 15-415 - C. Faloutsos

  19. P1 H A D F P2 G B E I P3 C J P4 R-trees - insertion • eg., rectangle ‘X’ P1 P3 I C A G H F B X J E P4 P2 D X 15-415 - C. Faloutsos

  20. P1 A H D F P2 G B E I P3 C J P4 skip R-trees - insertion • eg., rectangle ‘Y’ P1 P3 I C A G H F B J Y E P4 P2 D 15-415 - C. Faloutsos

  21. P1 A H D F P2 G B E I P3 C J P4 skip R-trees - insertion • eg., rectangle ‘Y’: extend suitable parent. P1 P3 I C A G H F B J Y E P4 P2 D Y 15-415 - C. Faloutsos

  22. skip R-trees - insertion • eg., rectangle ‘Y’: extend suitable parent. • Q: how to measure ‘suitability’? 15-415 - C. Faloutsos

  23. skip R-trees - insertion • eg., rectangle ‘Y’: extend suitable parent. • Q: how to measure ‘suitability’? • A: by increase in area (volume) (more details: later, under ‘performance analysis’) • Q: what if there is no room? how to split? 15-415 - C. Faloutsos

  24. P1 A H D F P2 G B E I P3 C J P4 skip R-trees - insertion • eg., rectangle ‘W’ P1 P3 K I C A G W H F B J K E P4 P2 D 15-415 - C. Faloutsos

  25. skip R-trees - insertion • eg., rectangle ‘W’ - focus on ‘P1’ - how to split? P1 K C A W B 15-415 - C. Faloutsos

  26. skip R-trees - insertion • eg., rectangle ‘W’ - focus on ‘P1’ - how to split? P1 • (A1: plane sweep, • until 50% of rectangles) • A2: ‘linear’ split • A3: quadratic split • A4: exponential split K C A W B 15-415 - C. Faloutsos

  27. seed2 R skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ seed1 15-415 - C. Faloutsos

  28. skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ • Q: how to measure ‘closeness’? 15-415 - C. Faloutsos

  29. skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ • Q: how to measure ‘closeness’? • A: by increase of area (volume) 15-415 - C. Faloutsos

  30. seed2 R skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ seed1 15-415 - C. Faloutsos

  31. seed2 R skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ seed1 15-415 - C. Faloutsos

  32. skip R-trees - insertion & split • pick two rectangles as ‘seeds’; • assign each rectangle ‘R’ to the ‘closest’ ‘seed’ • smart idea: pre-sort rectangles according to delta of closeness (ie., schedule easiest choices first!) 15-415 - C. Faloutsos

  33. skip R-trees - insertion - pseudocode • decide which parent to put new rectangle into (‘closest’ parent) • if overflow, split to two, using (say,) the quadratic split algorithm • propagate the split upwards, if necessary • update the MBRs of the affected parents. 15-415 - C. Faloutsos

  34. skip R-trees - insertion - observations • many more split algorithms exist (next!) 15-415 - C. Faloutsos

  35. skip SAMs - more detailed outline • R-trees • main idea; file structure • algorithms: insertion/split • deletion • search: range, nn, spatial joins • performance analysis • variations (packed; hilbert;...) 15-415 - C. Faloutsos

  36. skip R-trees - deletion • delete rectangle • if underflow • ?? 15-415 - C. Faloutsos

  37. skip R-trees - deletion • delete rectangle • if underflow • temporarily delete all siblings (!); • delete the parent node and • re-insert them 15-415 - C. Faloutsos

  38. SAMs - more detailed outline • R-trees • main idea; file structure • algorithms: insertion/split • deletion • search: range, nn, spatial joins • performance analysis • variations (packed; hilbert;...) 15-415 - C. Faloutsos

  39. R-trees - range search pseudocode: check the root for each branch, if its MBR intersects the query rectangle apply range-search (or print out, if this is a leaf) 15-415 - C. Faloutsos

  40. P1 P3 I C A G H F B J q E P4 P2 D skip R-trees - nn search 15-415 - C. Faloutsos

  41. P1 P3 I C A G H F B J q E P4 P2 D skip R-trees - nn search • Q: How? (find near neighbor; refine...) 15-415 - C. Faloutsos

  42. skip R-trees - nn search • A1: depth-first search; then, range query P1 P3 I C A G H F B J E P4 q P2 D 15-415 - C. Faloutsos

  43. skip R-trees - nn search • A1: depth-first search; then, range query P1 P3 I C A G H F B J E P4 q P2 D 15-415 - C. Faloutsos

  44. skip R-trees - nn search • A1: depth-first search; then, range query P1 P3 I C A G H F B J E P4 q P2 D 15-415 - C. Faloutsos

  45. skip R-trees - nn search • A2: [Roussopoulos+, sigmod95]: • priority queue, with promising MBRs, and their best and worst-case distance • main idea: 15-415 - C. Faloutsos

  46. P1 P3 I C A G H F B J E P4 P2 D skip R-trees - nn search consider only P2 and P4, for illustration q 15-415 - C. Faloutsos

  47. skip R-trees - nn search best of P4 => P4 is useless for 1-nn worst of P2 H J E P4 q P2 D 15-415 - C. Faloutsos

  48. skip R-trees - nn search • what is really the worst of, say, P2? worst of P2 E q P2 D 15-415 - C. Faloutsos

  49. skip R-trees - nn search • what is really the worst of, say, P2? • A: the smallest of the two red segments! q P2 15-415 - C. Faloutsos

  50. skip R-trees - nn search • variations: [Hjaltason & Samet] incremental nn: • build a priority queue • scan enough of the tree, to make sure you have the k nn • to find the (k+1)-th, check the queue, and scan some more of the tree • ‘optimal’ (but, may need too much memory) 15-415 - C. Faloutsos

More Related