Query Processing in Databases Dr. M. Gavrilova

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.
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.
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
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
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
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.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
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.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2001 Lecture 2 Chapter 2: Polygon Partitioning.
Brute-Force Triangulation
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
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,
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
Computational Geometry Course Summary (First Half) Spring 2008 Pay special attention to: algorithm details (able to explain correctness and carry out a.
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.
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.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Polygon Triangulation
Spatial Data Management
CMPS 3130/6130 Computational Geometry Spring 2017
3. Polygon Triangulation
Computer Graphics Implementation II
Computational Geometry
Introduction to Spatial Computing CSE 555
Computer Graphics CC416 Week 13 Clipping.
Tree-Structured Indexes
Visible-Surface Detection Methods
Fill Area Algorithms Jan
Algorithm design techniques Dr. M. Gavrilova
Sameh Shohdy, Yu Su, and Gagan Agrawal
Graphics Pipeline Clipping
External Sorting The slides for this text are organized into chapters. This lecture covers Chapter 11. Chapter 1: Introduction to Database Systems Chapter.
Polygon Triangulation
Implementation II Ed Angel Professor Emeritus of Computer Science
Selected Topics: External Sorting, Join Algorithms, …
I. The Problem of Molding
B+Trees The slides for this text are organized into chapters. This lecture covers Chapter 9. Chapter 1: Introduction to Database Systems Chapter 2: The.
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
Introduction to Computer Graphics with WebGL
Evaluation of Relational Operations: Other Techniques
Tree-Structured Indexes
Implementation II Ed Angel Professor Emeritus of Computer Science
Algorithms and Data Structures Lecture XIV
External Sorting Dina Said
Presentation transcript:

Query Processing in Databases Dr. M. Gavrilova CPSC 695 Week 6 Query Processing in Databases Dr. M. Gavrilova

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

Introduction 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.

Example 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!

PART 1 Techniques for large data sets External sorting Distributed sweeping Two-step processing

“External” sorting problem n pages in dataset on disk m pages of memory, m < n

“Divide and conquer” strategy 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 logmn )

Distributed sweeping 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 logmn + k ) algorithm, m – number of pages in RAM. Range query v Sweep-line

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

Distributed sweeping 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. v 1 2 3 4 end middle part

Distributed sweeping 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 logmn + k )

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

Two-step processing: Spatial Join Spatial predicates: Overlaps Contains Adjacent etc. 2 steps: Filter step Refinement step

Additional Database Specifics 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

PART 2 Computer Graphics Applications 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

Computer Graphic Primitives 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

Computer Graphic Primitives Polygon partitioning (for large data sets) Polygon triangulation Intersections (polyline, polygon)

Polygon partitioning 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.

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

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

Triangulation of a monotone polygon Idea: monotone polygons can be linearly triangulated. Simple polygon can be partitioned into monotone polygons. Monotone Simple

Triangulation of a monotone polygon 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 Convex partitioning – partitioning into convex components, can minimize the number of components, done in O(n).

Geometric Relationships Computing intersections: Point in a polygon Polyline intersection Polygon intersection (general and convex)

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

Polyline intersection Given a set of line segments. Detect if any 2 segments intersect. O(n2) – straightforward

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

Polygon intersection 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)

Convex polygon intersection 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.

Summary 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