Spatial Queries Nearest Neighbor and Join Queries.

Slides:



Advertisements
Similar presentations
The Optimal-Location Query
Advertisements

1 Spatial Join. 2 Papers to Present “Efficient Processing of Spatial Joins using R-trees”, T. Brinkhoff, H-P Kriegel and B. Seeger, Proc. SIGMOD, 1993.
Spatio-temporal Databases
Spatial Indexing SAMs. Spatial Indexing Point Access Methods can index only points. What about regions? Z-ordering and quadtrees Use the transformation.
Spatial and Temporal Data Mining V. Megalooikonomou Spatial Access Methods (SAMs) II (some slides are based on notes by C. Faloutsos)
Spatial Join Queries. Spatial Queries Given a collection of geometric objects (points, lines, polygons,...) organize them on disk, to answer point queries.
1 Top-k Spatial Joins
Nearest Neighbor Queries using R-trees
Searching on Multi-Dimensional Data
Nearest Neighbor Queries using R-trees Based on notes from G. Kollios.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
Progressive Computation of The Min-Dist Optimal-Location Query Donghui Zhang, Yang Du, Tian Xia, Yufei Tao* Northeastern University * Chinese University.
Efficient Reverse k-Nearest Neighbors Retrieval with Local kNN-Distance Estimation Mike Lin.
Continuous Intersection Joins Over Moving Objects Rui Zhang University of Melbourne Dan Lin Purdue University Kotagiri Ramamohanarao University of Melbourne.
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
1 CSIS 7101: CSIS 7101: Spatial Data (Part 2) Efficient Processing of Spatial Joins Using R-trees Rollo Chan Chu Chung Man Mak Wai Yip Vivian Lee Eric.
2-dimensional indexing structure
Spatio-temporal Databases Time Parameterized Queries.
Spatial Indexing SAMs. Spatial Indexing Point Access Methods can index only points. What about regions? Z-ordering and quadtrees Use the transformation.
Spatial Indexing for NN retrieval
Spatial Indexing SAMs. Spatial Access Methods PAMs Grid File kd-tree based (LSD-, hB- trees) Z-ordering + B+-tree R-tree Variations: R*-tree, Hilbert.
I/O-Algorithms Lars Arge Aarhus University February 16, 2006.
Spatial Indexing SAMs.
Spatial Queries Nearest Neighbor and Join Queries.
Spatial Queries Nearest Neighbor Queries.
Spatial Queries. R-tree: variations What about static datasets? (no ins/del) Hilbert What about other bounding shapes?
R-Trees 2-dimensional indexing structure. R-trees 2-dimensional version of the B-tree: B-tree of maximum degree 8; degree between 3 and 8 Internal nodes.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Advanced Data Structures NTUA 2007 R-trees and Grid File.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Spatial Indexing. Spatial Queries Given a collection of geometric objects (points, lines, polygons,...) organize them on disk, to answer point queries.
Indexing. Goals: Store large files Support multiple search keys Support efficient insert, delete, and range queries.
Spatial Data Management Chapter 28. Types of Spatial Data Point Data –Points in a multidimensional space E.g., Raster data such as satellite imagery,
Advanced Data Structures NTUA 2007 R-trees and Grid File.
Nearest Neighbor Queries Chris Buzzerd, Dave Boerner, and Kevin Stewart.
Spatial Query Processing Spatial DBs do not have a set of operators that are considered to be basic elements in a query evaluation. Spatial DBs handle.
Bin Yao (Slides made available by Feifei Li) R-tree: Indexing Structure for Data in Multi- dimensional Space.
On Computing Top-t Influential Spatial Sites Authors: T. Xia, D. Zhang, E. Kanoulas, Y.Du Northeastern University, USA Appeared in: VLDB 2005 Presenter:
9/2/2005VLDB 2005, Trondheim, Norway1 On Computing Top-t Most Influential Spatial Sites Tian Xia, Donghui Zhang, Evangelos Kanoulas, Yang Du Northeastern.
Bin Yao, Feifei Li, Piyush Kumar Presenter: Lian Liu.
Lecture 3: External Memory Indexing Structures (Contd) CS6931 Database Seminar.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
R-Trees: A Dynamic Index Structure For Spatial Searching Antonin Guttman.
1 CSIS 7101: CSIS 7101: Spatial Data (Part 1) The R*-tree : An Efficient and Robust Access Method for Points and Rectangles Rollo Chan Chu Chung Man Mak.
1 Reverse Nearest Neighbor Queries for Dynamic Databases SHOU Yu Tao Jan. 10 th, 2003 SIGMOD 2000.
Spatial Queries Nearest Neighbor and Join Queries Most slides are based on slides provided By Prof. Christos Faloutsos (CMU) and Prof. Dimitris Papadias.
1 Spatial Query Processing using the R-tree Donghui Zhang CCIS, Northeastern University Feb 8, 2005.
Spatial Data Management
Strategies for Spatial Joins
Many slides taken from George Kollios, Boston University
Multiway Search Trees Data may not fit into main memory
Spatial Indexing.
Spatial Indexing I Point Access Methods.
Advanced Algorithm Design and Analysis (Lecture 12)
Query Processing in Databases Dr. M. Gavrilova
KD Tree A binary search tree where every node is a
Nearest Neighbor Queries using R-trees
Query Processing and Optimization
Orthogonal Range Searching and Kd-Trees
R-tree: Indexing Structure for Data in Multi-dimensional Space
Spatio-temporal Databases
Introduction to Spatial Databases
Lecture 2- Query Processing (continued)
Spatial Indexing I R-trees
File Processing : Multi-dimensional Index
Spatio-temporal Databases
Multidimensional Search Structures
Liang Jin (UC Irvine) Nick Koudas (AT&T Labs Research)
C. Faloutsos Spatial Access Methods - R-trees
Data Mining CSCI 307, Spring 2019 Lecture 23
Presentation transcript:

Spatial Queries Nearest Neighbor and Join Queries

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer efficiently point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

R-tree … 2 3 5 7 8 4 6 11 10 9 2 12 1 13 3 1

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)

R-trees - NN search A B C D E F G H I J P1 P2 P3 P4 q

R-trees - NN search A B C D E F G H I J P1 P2 P3 P4 Q: How? (find near neighbor; refine...) A B C D E F G H I J P1 P2 P3 P4 q

R-trees - NN search P1 P3 I C A G F H B J E P4 P2 D A1: depth-first search; then range query P1 P3 I C A G F H B J E P4 q P2 D

R-trees - NN search P1 P3 I C A G F H B J E P4 P2 D A1: depth-first search; then range query P1 P3 I C A G F H B J E P4 q P2 D

R-trees - NN search P1 P3 I C A G F H B J E P4 P2 D A1: depth-first search; then range query P1 P3 I C A G F H B J E P4 q P2 D

R-trees - NN search: Branch and Bound A2: [Roussopoulos+, sigmod95]: At each node, priority queue, with promising MBRs, and their best and worst-case distance main idea: Every side (face) of any MBR contains at least one point of an actual spatial object!

MBR face property MBR is a d-dimensional rectangle, which is the minimal rectangle that fully encloses (bounds) an object (or a set of objects) MBR f.p.: Every face of the MBR contains at least one point of some object in the database

Search improvement Visit an MBR (node) only when necessary How to do pruning? Using MINDIST and MINMAXDIST

MINDIST MINDIST(P, R) is the minimum distance between a point P and a rectangle R If the point is inside R, then MINDIST=0 If P is outside of R, MINDIST is the distance of P to the closest point of R (one point of the perimeter)

MINDIST computation R u ri = li if pi < li p = ui if pi > ui MINDIST(p,R) is the minimum distance between p and R with corner points l and u the closest point in R is at least this distance away u=(u1, u2, …, ud) R u ri = li if pi < li = ui if pi > ui = pi otherwise p p MINDIST = 0 l p l=(l1, l2, …, ld)

MINMAXDIST MINMAXDIST(p,R): for each dimension, find the closest face, compute the distance to the furthest point on this face and take the minimum of all these (d) distances MINMAXDIST(p,R) is the smallest possible upper bound of distances from p to R MINMAXDIST guarantees that there is at least one object in R with a distance to p smaller or equal to it.

MINDIST and MINMAXDIST MINDIST(p, R) <= NN(p) <=MINMAXDIST(p,R) MINMAXDIST R1 R4 R3 MINDIST MINDIST MINMAXDIST MINDIST MINMAXDIST R2

Pruning in NN search Downward pruning: An MBR R is discarded if there exists another R’ s.t. MINDIST(p,R)>MINMAXDIST(p,R’) Downward pruning: An object O is discarded if there exists an R s.t. the Actual-Dist(p,O) > MINMAXDIST(p,R) Upward pruning: An MBR R is discarded if an object O is found s.t. the MINDIST(p,R) > Actual-Dist(p,O)

Pruning 1 example Downward pruning: An MBR R is discarded if there exists another R’ s.t. MINDIST(p,R)>MINMAXDIST(p,R’) R R’ MINDIST MINMAXDIST

Pruning 2 example Downward pruning: An object O is discarded if there exists an R s.t. the Actual-Dist(p,O) > MINMAXDIST(p,R) R Actual-Dist O MINMAXDIST

Pruning 3 example Upward pruning: An MBR R is discarded if an object O is found s.t. the MINDIST(p,R) > Actual-Dist(p,O) R MINDIST Actual-Dist O

Ordering Distance MINDIST is an optimistic distance where MINMAXDIST is a pessimistic one. MINDIST P MINMAXDIST

NN-search Algorithm Initialize the nearest distance as infinite distance Traverse the tree depth-first starting from the root. At each Index node, sort all MBRs using an ordering metric and put them in an Active Branch List (ABL). Apply pruning rules 1 and 2 to ABL Visit the MBRs from the ABL following the order until it is empty If Leaf node, compute actual distances, compare with the best NN so far, update if necessary. At the return from the recursion, use pruning rule 3 When the ABL is empty, the NN search returns.

K-NN search Keep the sorted buffer of at most k current nearest neighbors Pruning is done using the k-th distance

Another NN search: Best-First Global order [HS99] Maintain distance to all entries in a common Priority Queue Use only MINDIST Repeat Inspect the next MBR in the list Add the children to the list and reorder Until all remaining MBRs can be pruned

Nearest Neighbor Search (NN) with R-Trees Best-first (BF) algorihm: y axis Root 10 E 7 E E E E 1 2 3 1 e f E 2 1 2 8 8 E 8 E d E g E 2 5 1 6 E h i E E E E E E E 6 9 4 5 6 7 8 9 query point contents 5 5 9 13 2 17 4 E omitted b 4 a search region 2 c a b c d e f h g i E 3 5 13 18 13 13 10 2 13 10 x axis E 2 4 6 8 10 E E 4 5 8 Action Heap Result Visit Root E 1 E E {empty} 1 2 2 3 8 follow E 1 E E E E E {empty} 2 2 4 5 5 5 3 8 6 9 follow E E E E E E E 2 8 2 4 5 5 5 E 3 8 6 9 7 13 9 17 {empty} follow E h E E E E i E g 8 2 4 5 5 5 3 8 6 9 10 7 13 {empty} 13 E E E E i E g 4 5 5 5 3 8 6 9 10 7 13 13 {(h, 2 )} Report h and terminate

HS algorithm Initialize PQ (priority queue) InesrtQueue(PQ, Root) While not IsEmpty(PQ) R= Dequeue(PQ) If R is an object Report R and exit (done!) If R is a leaf page node For each O in R, compute the Actual-Dists, InsertQueue(PQ, O) If R is an index node For each MBR C, compute MINDIST, insert into PQ

Best-First vs Branch and Bound Best-First is the “optimal” algorithm in the sense that it visits all the necessary nodes and nothing more! But needs to store a large Priority Queue in main memory. If PQ becomes large, we have thrashing… BB uses small Lists for each node. Also uses MINMAXDIST to prune some entries

Spatial Queries Given a collection of geometric objects (points, lines, polygons, ...) organize them on disk, to answer point queries range queries k-nn queries spatial joins (‘all pairs’ queries)

Spatial Join Find all parks in each city in MA Find all trails that go through a forest in MA Basic operation find all pairs of objects that overlap Single-scan queries nearest neighbor queries, range queries Multiple-scan queries spatial join

Algorithms No existing index structures Transform data into 1-d space [O89] z-transform; sensitive to size of pixel Partition-based spatial-merge join [PW96] partition into tiles that can fit into memory plane sweep algorithm on tiles Spatial hash joins [LR96, KS97] Sort data using recursive partitioning [BBKK01] With index structures [BKS93, HJR97] k-d trees and grid files R-trees

R-tree based Join [BKS93]

Join1(R,S) S R Tree synchronized traversal algorithm Repeat Find a pair of intersecting entries E in R and F in S If R and S are leaf pages then add (E,F) to result-set Else Join1(E,F) Until all pairs are examined CPU and I/O bottleneck S R

CPU – Time Tuning Two ways to improve CPU – time Restricting the search space Spatial sorting and plane sweep

Reducing CPU bottleneck S R

Join2(R,S,IntersectedVol) Join2(R,S,IV) Repeat Find a pair of intersecting entries E in R and F in S that overlap with IV If R and S are leaf pages then add (E,F) to result-set Else Join2(E,F,CommonEF) Until all pairs are examined In general, number of comparisons equals size(R) + size(S) + relevant(R)*relevant(S) Reduce the product term

Restricting the search space Join1: 7 of R * 7 of S 5 1 = 49 comparisons 1 1 5 3 Now: 3 of R * 2 of S =6 comp Plus Scanning: 7 of R + 7 of S = 14 comp

Using Plane Sweep S R s1 s2 r1 r2 r3 Consider the extents along x-axis Start with the first entry r1 sweep a vertical line

Using Plane Sweep S R s1 s2 r1 r2 r3 Check if (r1,s1) intersect along y-dimension Add (r1,s1) to result set

Using Plane Sweep S R s1 s2 r1 r2 r3 Check if (r1,s2) intersect along y-dimension Add (r1,s2) to result set

Using Plane Sweep S R s1 s2 r1 r2 r3 Reached the end of r1 Start with next entry r2

Using Plane Sweep S R s1 s2 r1 r2 r3 Reposition sweep line

Using Plane Sweep S R s1 s2 r1 r2 r3 Check if r2 and s1 intersect along y Do not add (r2,s1) to result

Using Plane Sweep S R s1 s2 r1 r2 r3 Reached the end of r2 Start with next entry s1

Using Plane Sweep S R s1 s2 r1 r2 r3 Total of 2(r1) + 1(r2) + 0 (s1)+ 1(s2)+ 0(r3) = 4 comparisons

I/O Tunning Compute a read schedule of the pages to minimize the number of disk accesses Local optimization policy based on spatial locality Three methods Local plane sweep Local plane sweep with pinning Local z-order

Reducing I/O Plane sweep again: Read schedule r1, s1, s2, r3 Every subtree examined only once Consider a slightly different layout

Reducing I/O S R s1 r2 r1 s2 r3 Read schedule is r1, s2, r2, s1, s2, r3 Subtree s2 is examined twice

Pinning of nodes After examining a pair (E,F), compute the degree of intersection of each entry degree(E) is the number of intersections between E and unprocessed rectangles of the other dataset If the degrees are non-zero, pin the pages of the entry with maximum degree Perform spatial joins for this page Continue with plane sweep

Reducing I/O S R s1 r2 r1 s2 r3 After computing join(r1,s2), degree(r1) = 0 degree(s2) = 1 So, examine s2 next Read schedule = r1, s2, r3, r2, s1 Subtree s2 examined only once

Local Z-Order Idea: Compute the intersections between each rectangle of the one node and all rectangles of the other node Sort the rectangles according to the Z-ordering of their centers Use this ordering to fetch pages

Local Z-ordering Read schedule: <s1,r2,r1,s2,r4,r3> r3 III III IV IV II r1 r4 s1 I I r2 Read schedule: <s1,r2,r1,s2,r4,r3>

Number of Disk Access > 5384 5290 Size of LRU Buffer < 2373 2392

HMW 1 Answer set P: {a, i, k) Problem 1 Problem 2 a) compute the Z-values for the two regions. We can use up to 4 bits per dimension. b) write some simple code to compute the z-values and Hilbert-values of points in 2-d. You need to specify the first the resolution (how many bits per dimension) and then the x and y of the point. Also, you need to be able to compute the inverse. Again you specify the resolution and the value (z or Hilbert) and you give back the pixel location. Problem 2 Example of Skyline points: Answer set P: {a, i, k)