Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.

Slides:



Advertisements
Similar presentations
Polygon Triangulation
Advertisements

Spatial Information Systems (SIS) COMP Terrain modeling and geometric problems (part 2)
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Spatial Join Queries. Spatial Queries Given a collection of geometric objects (points, lines, polygons,...) organize them on disk, to answer point queries.
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Planar Orientations Chapter 4 ( ) in the book Written By: Tomer Heber.
Approximations of points and polygonal chains
Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.
Query Execution, Concluded Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems November 18, 2003 Some slide content may.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
Convex Hull obstacle start end Convex Hull Convex Hull
C o m p u t i n g C O N V E X H U L L S by Kok Lim Low 10 Nov 1998 COMP Presentation.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
Introduction to Spatial Database System Presented by Xiaozhi Yu.
Ruslana Mys Delaunay Triangulation Delaunay Triangulation (DT)  Introduction  Delaunay-Voronoi based method  Algorithms to compute the convex hull 
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Classes of Polygons Planar polygons Non-planar polygons Simple
Feb Polygon Triangulation Shmuel Wimer Bar Ilan Univ., School of Engineering.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2010 Lecture 2 Polygon Partitioning Thursday,
2-dimensional indexing structure
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Lecture 2 Chapter 2: Polygon Partitioning.
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
I/O-Algorithms Lars Arge University of Aarhus March 7, 2005.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2007 Lecture 2 Chapter 2: Polygon Partitioning.
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.
Area, buffer, description Area of a polygon, center of mass, buffer of a polygon / polygonal line, and descriptive statistics.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
Computational Geometry Convex Hulls Robust Geometric Primitives Degeneracy and Stability Nick Pilkington.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
Triangulating a monotone polygon
Spatial Data Management Chapter 28. Types of Spatial Data Point Data –Points in a multidimensional space E.g., Raster data such as satellite imagery,
SEMILARITY JOIN COP6731 Advanced Database Systems.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
C o m p u t i n g C O N V E X H U L L S. Presentation Outline 2D Convex Hulls –Definitions and Properties –Approaches: Brute Force Gift Wrapping QuickHull.
1 Triangulation Supplemental From O’Rourke (Chs. 1&2) Fall 2005.
Lars Arge Presented by Or Ozery. I/O Model Previously defined: N = # of elements in input M = # of elements that fit into memory B = # of elements per.
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.
Arrangements and Duality Sanjay Sthapit Comp290 10/6/98.
Arrangements and Duality Motivation: Ray-Tracing Fall 2001, Lecture 9 Presented by Darius Jazayeri 10/4/01.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 9 Line Arrangements.
Polygon Triangulation
Spatial Data Management
CMPS 3130/6130 Computational Geometry Spring 2017
3. Polygon Triangulation
Computer Graphics Filling.
Introduction to Polygons
Computer Graphics CC416 Week 13 Clipping.
Fill Area Algorithms Jan
Query Processing in Databases Dr. M. Gavrilova
Algorithm design techniques Dr. M. Gavrilova
Polygon Triangulation
Lecture 2- Query Processing (continued)
Evaluation of Relational Operations: Other Techniques
Algorithms and Data Structures Lecture XIV
Presentation transcript:

Query Processing in Databases Dr. M. Gavrilova

 Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying  Applications

 Geometric algorithms studied before dealt with RAM  In databases, a problem of accessing “pages” of memory stored on disk is encountered.  We will see how traditional algorithm design techniques can be useful.

 4 pages of memory, 10 items in each  To list all sequentially, 4 disks accesses is required  To randomly list items – up to 40 disk accesses is require if only 1 page is loaded in the memory once –too expensive!

 External sorting  Distributed sweeping  Two-step processing

 n pages in dataset on disk  m pages of memory, m < n

 Step 1. Sorted “runs” of size m are created in memory, then written to disk. Used internal sorting algorithms.  Step 2. Load some number of first records from each run into memory, merge them in the sorted order. Once a block is sorted, write it back to disk.  Complexity: O(n log m n )

Segment intersection problem, orthogonal segments. In RAM – sweep-line algorithm, O(n logn+k ) n – number of segments, k – number of intersections. In DB – O(n log m n + k ) algorithm, m – number of pages in RAM. Sweep-line Range query v

 Idea: split space by m horizontal strips, each contains approximately n/m segments.  Active list is created for each strip: L 1, L 2, …, L m.  When a vertical segment is met, it is tested against intersection with segment in active lists of strips that overlap with the segment v

 However, in the worst case, for all vertical segments all strips should be tested.  In the picture, segment v intersects strip 4, while no intersections are reported.  Solution: split each vertical segment into 3 parts: ◦ One lies completely within some number of strips ◦ Other two partially cover a strip end middle part v

 Test intersection between the vertical segment and all segments in “middle” strips  Then recursively do it for two “end” strips.  Recursion terminates when all processing can be carried out in RAM  O(n log m n + k )

 The same idea is carried out to the case of rectangle intersection  Θ(n log m n + k ) bound is met again

 Spatial predicates: ◦ Overlaps ◦ Contains ◦ Adjacent ◦ etc.  2 steps: ◦ Filter step ◦ Refinement step

 In databases: challenges with I/O (file access) are resolved using techniques discussed above.  Specific methods exist for: ◦ Grid files (linear structures) ◦ R-trees ◦ Unindexed collections of objects

 DB operations: windowing and clipping  Windowing(g,r) is a Boolean operator: to test if object g intersects rectangle r.  Clipping (g,r) computes part of g inside r g r g r

 Windowing: ◦ scan edges of g ◦ test for intersection with r ◦ checking vertices is not enough ◦ O(n)  Clipping: ◦ consider each edge of r as a half-plane ◦ clip g against each of those ◦ combine results ◦ O(n)

 Polygon partitioning (for large data sets)  Polygon triangulation  Intersections (polyline, polygon)

 Sort vertices of polygon P according to the X coordinate  Use sweep-line technique: vertical line L, for each vertex v compute the maximum vertical segment of L, internal to P and containing v. This is done by examining nearest edges above/below v.  The visibility segments define trapezoids.  Complexity O(n lg n)  Note: complex polygons can be triangulated, if trapezoids are further triangulated.

 The visibility segments define trapezoids (geometric object with 2 parallel edges)

 Triangulation involves finding diagonals within the polygon, i.e. segments v i v j between vertices of P.  v i and v j are said to be visible to each other.  Each triangulation of a polygon has (n-3) diagonals and (n-2) triangles

 Idea: monotone polygons can be linearly triangulated. Simple polygon can be partitioned into monotone polygons.  MonotoneSimple

 Idea: sweep-line, sort all vertices of P  If the angle between 3 previously processed points is convex  create a triangle, remove point from list L.  If reflex angle  add next point.  Partitioning a polygon into monotone polygons – similarly to trapezoidation, sweep-line by edges, find trapezoids, they represent monotone chains. O(n lg n)

 Convex partitioning – partitioning into convex components, can minimize the number of components, done in O(n).

 Computing intersections: ◦ Point in a polygon ◦ Polyline intersection ◦ Polygon intersection (general and convex)

 Draw a half-ray from p  Count # of intersections with the boundary  If odd  p is inside, even  outside  O(n) algorithm p q

 Given a set of line segments. Detect if any 2 segments intersect.  O(n 2 ) – straightforward

 Plane-sweep O(n lg n): 1.The line meets the leftmost point of S: S inserted in L, two neighboring segments below and above S are tested for intersection. 2.The line L meets the rightmost point of S: S is deleted, segments above and below S are tested for intersection. sweep

 Two simple polygons P and Q.  Possible cases: ◦ One edge of P intersects one edge of Q (use segment intersection test) ◦ P is inside Q (point inside polygon) ◦ Q is inside P (point inside polygon) ◦ Otherwise, P and Q don’t intersect.  O(n lg n)

 Convexity allows to devise a faster O(n) algorithm.  Idea: synchronized scan of edges of P and Q, so that all intersection points are eventually found and “inner” intersection boundary is known at each step.  Scanned edges are advanced if they “point” at each other.

 Dealing with large data sets requires additional resources  Some methods such as below can be useful: ◦ External sorting ◦ Distributed sweeping ◦ Two-step processing  Other applications (spatial map querying) require computer graphics primitives  Various intersection operations exist