Download presentation
Presentation is loading. Please wait.
1
Spatial Join
2
Outline Relational Join Difference between relational and spatial join
Spatial Join using R-trees
3
Relational Join Basic Join Algorithm Input: Relations R and S
Output: Joined relation T T=empty set FOR EACH record r in R FOR EACH record s in S IF r.a==s.a THEN append r||s to T Complexity: O(|R||S|) R S . : . :
4
More Efficient Join Hash-based join Sort-merge join
No need to sort both relations first. Relations have hash indices. Use hash to find the corresponding records. Sort-merge join Sort both relations first. Scan through both relations only once.
5
Hash-based Join Input: Relations R and S Output: Joined relation T
T=empty set FOR EACH record r in R FOR EACH record s in hash(S, r.a) IF r.a==s.a THEN append r||s to T Complexity: O(|R||bucket|) R S . : . :
6
Sort-merge Join Input: Sorted relations R and S
Output: Joined relation T T=empty set. RP = pointer to the first record in R. SP = pointer to the first record in S. WHILE (RP is not null) { WHILE (*RP.a *SP.a) { IF (*RP.a == *SP.a) THEN add *RP||*SP to T SP++ } RP++ R S … a 2 3 5 8 … a 1 2 4 5 6 T 2 5 Complexity: O(|R|+|S|)
7
Spatial Join Hash-based join Sort-merge join
Spatial join using R-trees Seeded trees Sort-merge join Iterative spatial join
8
Spatial Join Using R-trees
Input: nodes R, S in R-trees. r_tree_join (R, S: node) IF (R, S are leaf nodes) THEN RETURN all overlapping objects in R and S FOR EACH r in R.children DO FOR EACH s Î S.children DO IF intersect (r,s) THEN r_tree_join (r,s) ;
9
Example: Spatial Join Using R-trees
10
Seeded Trees One relation, say R, has an R-tree as an index, but another relation, say S, has no index. Create an R-tree for the relation S, using the structure of the R-tree for the relation R. Advantage: Minimize the number of overlapping MBRs for two trees.
11
Iterative Spatial Join
Similar to sort-merge join Plane sweep method Sort MBRs of objects in both relations by their lower bounds in the chosen dimension. Initialize sweep structures of A and B For each MBR X in the sorted list: Update the sweep structure of the other relation. Find MBRs in the sweep structure of other relation which overlaps X. Good for limited main memory
12
Example:Iterative Spatial Join
1 5 B 2 4 C 3 6 A D
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.