110 likes | 347 Views
R-Trees. Presented By N Jaggan 2001A4A7223. Spatial Data Objects. Cover Multi-Dimensional Spaces Not Represented well by Points Examples include Maps objects like countries, Data elements like gears etc in a machine drawing etc. Why indexing?. Queries should take least possible time
E N D
R-Trees Presented By N Jaggan 2001A4A7223
Spatial Data Objects • Cover Multi-Dimensional Spaces • Not Represented well by Points • Examples include Maps objects like countries, Data elements like gears etc in a machine drawing etc.
Why indexing? • Queries should take least possible time • Common Queries include: • Range Queries: An example is find all countries within 500 km from a point. These type of queries occur frequently in CAD and Geographic Info Systems.
Why not traditional index Structures? • Hash Tables: Not useful as range search is required. • B-Trees: Are one dimensional whereas search space is multidimensional. • Quad Trees & k-d Trees: Do not take paging of secondary memory into account.
R-Tree Index Structure • R-Tree is height balanced Tree similar to B-Tree. • Leaf Nodes contain pointers to data objects. • Insertions and Deletions are dynamic and can be done in any order. • Spatial Database contains a list of tuples.
R-Tree Structure • Each tuple has a unique identifier. • Leaf nodes index records of the form (I,tuple-id). where I is the n-dimensional bounding rectangle of the spatial object. I=(I0,I1…….In) where each Ii is the extent along dimension i.
R-Tree Structure • Non leaf entries are of the form (I,child pointer). I covers all rectangles of the lower node entries. Notation. M: Maximum number of entries in a node m: parameter specifying minimum number of entries in a node.
Searching • Given R-tree with root T and find all records overlap with Search rectangle S. • If T is not leaf, check each entry E to determine whether Ei overlaps with S. • For all overlapping entries invoke search on each of them with root as node pointed by Ep. • If T is a leaf check each entry E. If it overlaps output it.
Insertion • Find position for new record.Let it be L. • Start with the root and go down each level finding the rectangle which needs the least enlargement.. • If there is space in L add record to L • Otherwise split L • Propagate changes upwards -Starting from L, go up and change covering rectangles. Propagate splits upwards if there is no room. • If root is split, create a new root.
Deletion • Remove index node E from R-Tree. • Find node containing record. • Remove E. • If node contains fewer than m records remove the node and add it to Q. • Move up and do the same reducing covering rectangles. • Reinsert all records in Q.