Nearest Neighbor Queries using R-trees

Slides:



Advertisements
Similar presentations
CSIS 7101: Spatial Data (Part 3) Distance Browsing in Spatial Database GÍSLI R. HJALTASON and HANAN SAMET Rollo Chan Chu Chung Man Mak Wai Yip Vivian Lee.
Advertisements

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
On Spatial-Range Closest Pair Query Jing Shan, Donghui Zhang and Betty Salzberg College of Computer and Information Science Northeastern University.
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
Nearest Neighbor Queries using R-trees
Searching on Multi-Dimensional Data
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
Nearest Neighbor Queries using R-trees Based on notes from G. Kollios.
Progressive Computation of The Min-Dist Optimal-Location Query Donghui Zhang, Yang Du, Tian Xia, Yufei Tao* Northeastern University * Chinese University.
1 NNH: Improving Performance of Nearest- Neighbor Searches Using Histograms Liang Jin (UC Irvine) Nick Koudas (AT&T Labs Research) Chen Li (UC Irvine)
Efficient Reverse k-Nearest Neighbors Retrieval with Local kNN-Distance Estimation Mike Lin.
Nearest Neighbor Search in Spatial and Spatiotemporal Databases
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.
Liang Jin (UC Irvine) Nick Koudas (AT&T) Chen Li (UC Irvine)
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.
Spatial Indexing SAMs.
Spatial Queries Nearest Neighbor and Join Queries.
Nearest Neighbor Queries Sung-hsun Su April 12, 2001
Spatial Queries Nearest Neighbor Queries.
I/O-Algorithms Lars Arge Aarhus University March 6, 2007.
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.
Advanced Data Structures NTUA 2007 R-trees and Grid File.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
B-trees and kd-trees Piotr Indyk (slides partially by Lars Arge from Duke U)
A Quantitative Analysis and Performance Study For Similar- Search Methods In High- Dimensional Space Presented By Umang Shah Koushik.
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.
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.
Location-based Spatial Queries AGM SIGMOD 2003 Jun Zhang §, Manli Zhu §, Dimitris Papadias §, Yufei Tao †, Dik Lun Lee § Department of Computer Science.
Progressive Computation of The Min-Dist Optimal-Location Query Donghui Zhang, Yang Du, Tian Xia, Yufei Tao* Northeastern University * Chinese University.
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.
1 R-Trees Guttman. 2 Introduction Range queries in multiple dimensions: Computer Aided Design (CAD) Geo-data applications Support special data objects.
Spatial Data Management
Mehdi Kargar Department of Computer Science and Engineering
Strategies for Spatial Joins
Many slides taken from George Kollios, Boston University
Spatial Queries Nearest Neighbor and Join Queries.
Multiway Search Trees Data may not fit into main memory
Advanced Algorithm Design and Analysis (Lecture 12)
KD Tree A binary search tree where every node is a
Analysis and design of algorithm
Orthogonal Range Searching and Kd-Trees
R-tree: Indexing Structure for Data in Multi-dimensional Space
Spatio-temporal Databases
Introduction to Spatial Databases
Spatio-Temporal Databases
Ch. 8 Priority Queues And Heaps
Spatial Indexing I R-trees
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:

Nearest Neighbor Queries using R-trees Based on notes from NTUA

Nearest Neighbor Search Find the object nearest to a query point q E.g., find the gas station nearest to the red point. k nearest neighbors: Find the k objects nearest to q E.g., 1 NN = {h}, 2NN = {h, a}, 3NN = {h, a, i}

R-trees - NN search 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 q P2 D

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

NN search: Best-First Global order [HjaltasonSamet99] 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 h i E 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 E E {empty} 1 1 2 2 3 8 follow E E E E E 1 E {empty} 2 2 4 5 5 5 3 8 6 9 follow E E E E E E E E 2 8 2 4 5 5 5 3 8 6 9 7 13 9 17 {empty} follow E E E E E E E 8 4 5 5 5 3 8 6 9 7 13 9 17 {(h, 2 )} g E E E i E 4 5 5 5 3 8 E 6 9 10 7 13 13 Report h and terminate

HS algorithm Initialize PQ (priority queue) InsertQueue(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

Analysis - Overview Analyze the situation after finding the k nearest neighbors Let o be the kth nearest neighbor of q, let r be the distance of o from q. The region within distance r from q is called the search region. Since we assume that q is a point, the search region is a circle (or a hypersphere in higher dimensions) with radius r. All objects inside the search region have already been reported by the algorithm (as the next nearest object), while all nodes intersecting the search region have been examined and their contents put on the priority queue. The contents of the priority queue are contained in nodes intersecting the boundary of the search region. The algorithm does not access any nodes or objects that lie entirely outside the search region (i.e., that are farther from q than o is).

R-trees - NN search: Branch and Bound Based on: [Roussopoulos+, sigmod95]: At each node, priority queue, with promising MBRs, and their best and worst-case distance main idea: Every 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.

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

References: Branch and Bound NN search: N. Roussopoulos, S. Kelley, F. Vincent: Nearest Neighbor Queries. SIGMOD Conference 1995: 71-79 Best First NN search: G.R. Hjaltason, H. Samet: Distance Browsing in Spatial Databases. ACM Trans. Database Syst. 24(2): 265-318 (1999)

Some follow up works D. Park, H. Kim: An Enhanced Technique for k-Nearest Neighbor Queries with Non-Spatial Selection Predicates. In Multimedia Tools and Applications archive, Volume 19 , Issue 1 (January 2003), Pages: 79 – 103 Ian De Felipe, Vagelis Hristidis, Naphtali Rishe. Keyword Search on Spatial Databases. IEEE ICDE 2008