key h(key) Hash Indexing Friday, April 09, 2004 Disadvantages of Sequential File Organization Must use an index and/or binary search to locate data

Similar documents
Hashing file organization

Chapter 12: Indexing and Hashing (Cnt(

Chapter 12: Indexing and Hashing. Basic Concepts

Chapter 12: Indexing and Hashing

Chapter 12: Indexing and Hashing

Chapter 11: Indexing and Hashing

Hash-Based Indexes. Chapter 11

Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Database System Concepts, 5th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Chapter 11: Indexing and Hashing" Chapter 11: Indexing and Hashing"

Chapter 11: Indexing and Hashing

Chapter 11: Indexing and Hashing

CS143: Index. Book Chapters: (4 th ) , (5 th ) , , 12.10

Chapter 17. Disk Storage, Basic File Structures, and Hashing. Records. Blocking

Topics to Learn. Important concepts. Tree-based index. Hash-based index

Access Methods. Basic Concepts. Index Evaluation Metrics. search key pointer. record. value. Value

Chapter 11: Indexing and Hashing

Database index structures

Module 3: Hashing Lecture 9: Static and Dynamic Hashing. The Lecture Contains: Static hashing. Hashing. Dynamic hashing. Extendible hashing.

CS34800 Information Systems

Indexing: Overview & Hashing. CS 377: Database Systems

QUIZ: Buffer replacement policies

CSIT5300: Advanced Database Systems

Hash-Based Indexes. Chapter 11. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Selection Queries. to answer a selection query (ssn=10) needs to traverse a full path.

Hash-Based Indexing 1

Hashed-Based Indexing

Symbol Table. Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management

Hash-Based Indexes. Chapter 11 Ramakrishnan & Gehrke (Sections ) CPSC 404, Laks V.S. Lakshmanan 1

Hashing. Data organization in main memory or disk

2, 3, 5, 7, 11, 17, 19, 23, 29, 31

Darshan Institute of Engineering & Technology

Hashing Techniques. Material based on slides by George Bebis

TUTORIAL ON INDEXING PART 2: HASH-BASED INDEXING

Lecture 8 Index (B+-Tree and Hash)

CS232A: Database System Principles INDEXING. Indexing. Indexing. Given condition on attribute find qualified records Attr = value

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5.

Chapter 1 Disk Storage, Basic File Structures, and Hashing.

Systems Infrastructure for Data Science. Web Science Group Uni Freiburg WS 2014/15

Data and File Structures Chapter 11. Hashing

Introduction to File Structures

Hash Table and Hashing

Indexing and Hashing

Chapter 13 Disk Storage, Basic File Structures, and Hashing.

Understand how to deal with collisions

Chapter 6. Hash-Based Indexing. Efficient Support for Equality Search. Architecture and Implementation of Database Systems Summer 2014

File Structures and Indexing

Data Storage and Query Answering. Indexing and Hashing (5)

Introduction to Data Management. Lecture 15 (More About Indexing)

Hashing IV and Course Overview

SUMMARY OF DATABASE STORAGE AND QUERYING

Intro to DB CHAPTER 12 INDEXING & HASHING

CARNEGIE MELLON UNIVERSITY DEPT. OF COMPUTER SCIENCE DATABASE APPLICATIONS

Introduction hashing: a technique used for storing and retrieving information as quickly as possible.

Fundamentals of Database Systems Prof. Arnab Bhattacharya Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

File System Interface and Implementation

Database Applications (15-415)

Indexing. Week 14, Spring Edited by M. Naci Akkøk, , Contains slides from 8-9. April 2002 by Hector Garcia-Molina, Vera Goebel

Introduction to Hashing

Announcements. Reading Material. Recap. Today 9/17/17. Storage (contd. from Lecture 6)

Kathleen Durant PhD Northeastern University CS Indexes

Comp 335 File Structures. Hashing

Module 5: Hash-Based Indexing

CS 525: Advanced Database Organization 04: Indexing

Hash Tables Outline. Definition Hash functions Open hashing Closed hashing. Efficiency. collision resolution techniques. EECS 268 Programming II 1

Database Technology. Topic 7: Data Structures for Databases. Olaf Hartig.

File Directories Associated with any file management system and collection of files is a file directories The directory contains information about

Database Applications (15-415)

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

Hashing. Hashing Procedures

Module 5: Hashing. CS Data Structures and Data Management. Reza Dorrigiv, Daniel Roche. School of Computer Science, University of Waterloo

More B-trees, Hash Tables, etc. CS157B Chris Pollett Feb 21, 2005.

CS 222/122C Fall 2016, Midterm Exam

Hash Tables. Johns Hopkins Department of Computer Science Course : Data Structures, Professor: Greg Hager

COMP171. Hashing.

Advances in Data Management Principles of Database Systems - 2 A.Poulovassilis

Data Structure Lecture#22: Searching 3 (Chapter 9) U Kang Seoul National University

Physical Database Design: Outline

Chapter 13: Indexing. Chapter 13. ? value. Topics. Indexing & Hashing. value. Conventional indexes B-trees Hashing schemes (self-study) record

BBM371& Data*Management. Lecture 6: Hash Tables

Storage hierarchy. Textbook: chapters 11, 12, and 13

CITS2200 Data Structures and Algorithms. Topic 15. Hash Tables

Outlook. File-System Interface Allocation-Methods Free Space Management

4 Hash-Based Indexing

Hashing. October 19, CMPE 250 Hashing October 19, / 25

CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course

SMD149 - Operating Systems - Memory

Indexing and Hashing

Material You Need to Know

A HASHING TECHNIQUE USING SEPARATE BINARY TREE

Database Applications (15-415)

Hash Tables. Hashing Probing Separate Chaining Hash Function

The Grid File: An Adaptable, Symmetric Multikey File Structure

Hashing. Introduction to Data Structures Kyuseok Shim SoEECS, SNU.

CS 350 Algorithms and Complexity

Hashing. Dr. Ronaldo Menezes Hugo Serrano. Ronaldo Menezes, Florida Tech

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

Indexing Methods. Lecture 9. Storage Requirements of Databases

CSE 562 Database Systems

Hashing. 1. Introduction. 2. Direct-address tables. CmSc 250 Introduction to Algorithms

Transcription:

Lectures Desktop (C) Page 1 Hash Indexing Friday, April 09, 004 11:33 AM Disadvantages of Sequential File Organization Must use an index and/or binary search to locate data File organization based on hashing allow us to avoid accessing an index structure. Also provides a way to construct indices. A bucket is a unit of storage containing one or more records (a bucket is typically a disk block). In a hash file organization we obtain the bucket of a record directly from its search-key value using a hash function. Hash function h is a function from the set of all search-key values K to the set of all bucket addresses B. Hash function is used to locate records for access, insertion as well as deletion. Records with different search-key values may be mapped to the same bucket; thus entire bucket has to be searched sequentially to locate a record. key h(key) <key>. Buckets (typically 1 disk block)

Lectures Desktop (C) Page. Bank Account Example There are 10 buckets, The binary representation of the ith character is assumed to be the integer i. The hash function returns the sum of the binary representations of the characters modulo 10 E.g. h(perryridge) = 5 h(round Hill) = 3 h(brighton) = 3 Hash Functions Worst has function maps all search-key values to the same bucket; this makes access time proportional to the number of search-key values in the file. An ideal hash function is uniform, i.e., each bucket is assigned the same number of search-key values from the set of all possible values. Ideal hash function is random, so each bucket will have the same number of records assigned to it irrespective of the actual distribution of search-key values in the file. Typical hash functions perform computation on the internal binary representation of the search-key. For example, for a string search-key, the binary representations of all the characters in the string could be added and the sum modulo the number of buckets could be returned..

Lectures Desktop (C) Page 3 Key = x1 x xn n byte character string Have b buckets h: add x1 + x +.. xn compute sum modulo b Example with records per bucket Insert h(e) = 1 Delete e f c INSERT: h(a) = 1 h(b) = h(c) = 1 h(d) = 0 0 1 3 Bucket Overflow

Lectures Desktop (C) Page 4 Bucket overflow can occur because of Insufficient buckets Skew in distribution of records. This can occur due to two reasons: multiple records have same search-key value chosen hash function produces non-uniform distribution of key values Although the probability of bucket overflow can be reduced, it cannot be eliminated; it is handled by using overflow buckets. Overflow chaining the overflow buckets of a given bucket are chained together in a linked list. Above scheme is called closed hashing. An alternative, called open hashing, which does not use overflow buckets, is not suitable for database applications. What about secondary indices, or cases where the file

Lectures Desktop (C) Page 5 organization may already be sequential? Use Hash Indices... Hashing can be used not only for file organization, but also for index-structure creation. A hash index organizes the search keys, with their associated record pointers, into a hash file structure. Strictly speaking, hash indices are always secondary indices if the file itself is organized using hashing, a separate primary hash index on it using the same search-key is unnecessary. However, we use the term hash index to refer to both secondary index structures and hash organized files. Hash Index Example

Lectures Desktop (C) Page 6 What are the deficiencies of static hashing? In static hashing, function h maps search-key values to a fixed set of B of bucket addresses. Databases grow with time. If initial number of buckets is too small, performance will degrade due to too much overflows. If file size at some point in the future is anticipated and number of buckets allocated accordingly, significant amount of space will be wasted initially. If database shrinks, again space will be wasted. One option is periodic re-organization of the file with a new hash function, but it is very expensive. These problems can be avoided by using techniques that allow the number of buckets to be modified dynamically. Thus, the topic of dynamic hashing...

Lectures Desktop (C) Page 7 Good for database that grows and shrinks in size Allows the hash function to be modified dynamically Extendable (aka extensible) hashing one form of dynamic hashing Hash function generates values over a large range typically b-bit integers, with b = 3. At any time use only a prefix of the hash function to index into a table of bucket addresses. Let the length of the prefix be i bits, 0 i 3. Bucket address table size = i. Initially i = 0 Value of i grows and shrinks as the size of the database grows and shrinks. Multiple entries in the bucket address table may point to a bucket. Thus, actual number of buckets is < i The number of buckets also changes dynamically due to coalescing and splitting of buckets. So two ideas combine in extendable hashing: (a) Use i of b bits output by hash function b h(k) 00110101 use i grows over time.

Lectures Desktop (C) Page 8 (b) Use directory h(k)[i ].. to bucket Example: h(k) is 4 bits; keys per bucket Directory Buckets i = 1 1 0001 Track the number of bits used in placement within this bucket 1 1001 1100 Insert 1010

Lectures Desktop (C) Page 9 Insert: 0111 0000 Insert: 0000 1001 i = 0001 00 0111 01 10 11 1001 1010 1100

Lectures Desktop (C) Page 10 Extensible hashing: deletion No merging of blocks Merge blocks and cut directory if possible (Reverse insert procedure)