Arch (A) Tented Arch (T) Whorl (W) Loop (U or R) The four main classes of fingerprints Loop (60%) Arch/Tented Arch (6%) Whorl (34%) Other (Less than 1%)

Slides:



Advertisements
Similar presentations
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part C Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
Advertisements

Hash-Based Indexes Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY.
Hashing Dashiell Fryer CS 157B Dr. Lee. Contents Static Hashing Static Hashing File OrganizationFile Organization Properties of the Hash FunctionProperties.
Hash-based Indexes CS 186, Spring 2006 Lecture 7 R &G Chapter 11 HASH, x. There is no definition for this word -- nobody knows what hash is. Ambrose Bierce,
1 Hash-Based Indexes Module 4, Lecture 3. 2 Introduction As for any index, 3 alternatives for data entries k* : – Data record with key value k – –Choice.
Hash-Based Indexes The slides for this text are organized into chapters. This lecture covers Chapter 10. Chapter 1: Introduction to Database Systems Chapter.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11.
Quick Review of Apr 10 material B+-Tree File Organization –similar to B+-tree index –leaf nodes store records, not pointers to records stored in an original.
Department of Computer Science and Engineering, HKUST Slide 1 Dynamic Hashing Good for database that grows and shrinks in size Allows the hash function.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11.
CPSC 404, Laks V.S. Lakshmanan1 Hash-Based Indexes Chapter 11 Ramakrishnan & Gehrke (Sections )
Chapter 11 Indexing and Hashing (2) Yonsei University 2 nd Semester, 2013 Sanghyun Park.
File Processing : Hash 2015, Spring Pusan National University Ki-Joune Li.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 11: Indexing.
Chapter 11 (3 rd Edition) Hash-Based Indexes Xuemin COMP9315: Database Systems Implementation.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
CST203-2 Database Management Systems Lecture 7. Disadvantages on index structure: We must access an index structure to locate data, or must use binary.
Hash Indexes: Chap. 11 CS634 Lecture 6, Feb
Index tuning Hash Index. overview Introduction Hash-based indexes are best for equality selections. –Can efficiently support index nested joins –Cannot.
ICS 421 Spring 2010 Indexing (2) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/23/20101Lipyeow Lim.
1 Hash-Based Indexes Yanlei Diao UMass Amherst Feb 22, 2006 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
B+-tree and Hashing.
B+-tree and Hash Indexes
1 Hash-Based Indexes Chapter Introduction  Hash-based indexes are best for equality selections. Cannot support range searches.  Static and dynamic.
FALL 2004CENG 3511 Hashing Reference: Chapters: 11,12.
1 Hash-Based Indexes Chapter Introduction : Hash-based Indexes  Best for equality selections.  Cannot support range searches.  Static and dynamic.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
Quick Review of material covered Apr 8 B+-Tree Overview and some definitions –balanced tree –multi-level –reorganizes itself on insertion and deletion.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Hashing.
Computing & Information Sciences Kansas State University Friday, 24 Oct 2008CIS 560: Database System Concepts Lecture 23 of 42 Friday, 24 October 2008.
Chapter 11 Indexing & Hashing. 2 n Sophisticated database access methods n Basic concerns: access/insertion/deletion time, space overhead n Indexing 
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
12.1 Chapter 12: Indexing and Hashing Spring 2009 Sections , , Problems , 12.7, 12.8, 12.13, 12.15,
Hashing and Hash-Based Index. Selection Queries Yes! Hashing  static hashing  dynamic hashing B+-tree is perfect, but.... to answer a selection query.
1 Database Systems ( 資料庫系統 ) November 8, 2004 Lecture #9 By Hao-hua Chu ( 朱浩華 )
Indexing and Hashing By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 11 Modified by Donghui Zhang Jan 30, 2006.
Introduction to Database, Fall 2004/Melikyan1 Hash-Based Indexes Chapter 10.
1.1 CS220 Database Systems Indexing: Hashing Slides courtesy G. Kollios Boston University via UC Berkeley.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Indexed Sequential Access Method.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Hash-Based Indexes Chapter 10.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module D: Hashing.
B-Trees, Part 2 Hash-Based Indexes R&G Chapter 10 Lecture 10.
1 Database Systems ( 資料庫系統 ) November 28, 2005 Lecture #9.
Hash-Based Indexes. Introduction uAs for any index, 3 alternatives for data entries k*: w Data record with key value k w w Choice orthogonal to the indexing.
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Hash 2004, Spring Pusan National University Ki-Joune Li.
COP Introduction to Database Structures
Dynamic Hashing (Chapter 12)
Hash-Based Indexes Chapter 11
Dynamic Hashing.
Hashing Chapter 11.
Introduction to Database Systems
CS222: Principles of Data Management Notes #8 Static Hashing, Extendible Hashing, Linear Hashing Instructor: Chen Li.
Hash-Based Indexes R&G Chapter 10 Lecture 18
Hash-Based Indexes Chapter 10
Indexing and Hashing Basic Concepts Ordered Indices
CS222P: Principles of Data Management Notes #8 Static Hashing, Extendible Hashing, Linear Hashing Instructor: Chen Li.
Hashing.
Hash-Based Indexes Chapter 11
Index tuning Hash Index.
Indexing and Hashing B.Ramamurthy Chapter 11 2/5/2019 B.Ramamurthy.
Database Systems (資料庫系統)
LINEAR HASHING E0 261 Jayant Haritsa Computer Science and Automation
2018, Spring Pusan National University Ki-Joune Li
Module 12a: Dynamic Hashing
Index tuning Hash Index.
Hash-Based Indexes Chapter 11
Chapter 11 Instructor: Xin Zhang
CS222/CS122C: Principles of Data Management UCI, Fall 2018 Notes #07 Static Hashing, Extendible Hashing, Linear Hashing Instructor: Chen Li.
Presentation transcript:

Arch (A) Tented Arch (T) Whorl (W) Loop (U or R) The four main classes of fingerprints Loop (60%) Arch/Tented Arch (6%) Whorl (34%) Other (Less than 1%) (accidentals) Distribution of classes (Caucasian) Johannes Purkinje

No Normal Class on Thursday!! Instead I will be in my office, and the TAs will be in the TA lab, to answer questions about any section of the material covered since day one. Congratulations to Foula, who passed her qualifying exams with the highest grade!

1) R Thumb 16 2) R Index 16 3) R Middle 8 4) R Ring 8 5) R Little 4 6) L Thumb 4 7) L Index 2 8) L Middle 2 9) L Ring 1 10) L Little 1 U W A U A A U U W U The Henry Classification System 1) R Thumb2) R Index3) R Middle4) R Ring 8 5) R Little 6) L Thumb7) L Index8) L Middle9) L Ring 1 10) L Little = The sum of the values of the white squares that contain a Whorl (plus one) is the numerator of the primary classification. The sum of the values of the dark squares that contain a Whorl (plus one) is the denominator of the primary classification. Sir Edward Henry

The Henry Classification System II = 1) R Thumb 2) R Index3) R Middle4) R Ring 8 5) R Little 6) L Thumb7) L Index 2 8) L Middle9) L Ring 1 10) L Little = 1) R Thumb 2) R Index3) R Middle4) R Ring5) R Little 6) L Thumb 4 7) L Index8) L Middle9) L Ring 1 10) L Little   You cannot “simplify” the classes by canceling above and below the fraction bar. Read as “Ten over Four” not as “ten fourths” 10 4

The Henry Classification System III How many different classifications are there? Each finger position has exactly 2 possibilities, either it contains a Whorl or it does not. There are 5 positions in the numerator, so there are 2 5 possible numerators. The same argument is holds for the denominator. So the number of possible numerators times the number of possible denominators is 2 5 * 2 5 = 2 10 = 1024 Some of the 1024 “bins” in Scotland Yards Fingerprint Bureau during the 1950s

Static Hashing 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.

Static Hashing With hash based indexing, we assume that we have a function h, which tells us where to place any given record. Data Page 1 Data Page 2 Data Page 3 Data Page N-1 Data Page N h :::

Static Hashing The hash function usually takes the last k bits of the search key, multiples it by a, and adds b to get some value. The id of the page to access is identified by… page_number = h(value) mod N The values of a and b must be carefully selected, N should be prime. We desired the hash function to uniform and random (explained later).

Static Hashing As with ISAM, insertion can cause overflow. The solution is to create chains of overflow pages. Data Page 1 Data Page 2 Data Page 3 Data Page N-1 Data Page N h ::: Overflow for 3

Note about Notation Our book, and more generally the world, is inconsistent about notation. The page number that we should place our record in is sometimes given as… page_number = h(value) mod N And sometimes as… page_number = h(value) There is nothing “deep” going on here, it is just that the “Mod N” has been moved inside the notation in the second case.

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.

Handling of Bucket Overflows 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.

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.

Deficiencies of Static Hashing …These problems can be avoided by using techniques that allow the number of buckets to be modified dynamically. This is called dynamic hashing. There are several types of dynamic hashing, we will learn about extendible hashing, and linear hashing. First we must learn about hash indices.

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.

Example of Hash Index h

Extendable Hashing (Formal) Extendable hashing – one form of dynamic hashing –Hash function generates values over a large range — typically b-bit integers, with b = 32. –At any time use only a prefix (or suffix) of the hash function to index into a table of bucket addresses. –Let the length of the prefix (or suffix) be i bits, 0  i  32. –Bucket address table size = 2 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 < 2 i The number of buckets also changes dynamically due to coalescing and splitting of buckets.

Use of Extendable Hash Structure (Formal) Each bucket j stores a value i j ; all the entries that point to the same bucket have the same values on the first i j bits. To locate the bucket containing search-key K j : 1.Compute h(K j ) = X 2.Use the first i high order bits of X as a displacement into bucket address table, and follow the pointer to appropriate bucket To insert a record with search-key value K j –follow same procedure as look-up and locate the bucket, say j. –If there is room in the bucket j insert record in the bucket. –Else the bucket must be split and insertion re-attempted (next slide.) Overflow buckets used instead in some cases (will see shortly)

Updates in Extendable Hash Structure(Formal) Updates in Extendable Hash Structure (Formal) If i > i j (more than one pointer to bucket j) –allocate a new bucket z, and set i j and i z to the old i j –make the second half of the bucket address table entries pointing to j to point to z –remove and reinsert each record in bucket j. –recompute new bucket for K j and insert record in the bucket (further splitting is required if the bucket is still full) If i = i j (only one pointer to bucket j) –increment i and double the size of the bucket address table. –replace each entry in the table by two entries that point to the same bucket. –recompute new bucket address table entry for K j Now i > i j so use the first case above. To split a bucket j when inserting record with search-key value K j :

Updates in Extendable Hash Structure (Cont.) (Formal) When inserting a value, if the bucket is full after several splits (that is, i reaches some limit b) create an overflow bucket instead of splitting bucket entry table further. To delete a key value, –locate it in its bucket and remove it. –The bucket itself can be removed if it becomes empty (with appropriate updates to the bucket address table). –Coalescing of buckets can be done (can coalesce only with a “buddy” bucket having same value of i j and same i j –1 prefix, if it is present) –Decreasing bucket address table size is also possible Note: decreasing bucket address table size is an expensive operation and should be done only if number of buckets becomes much smaller than the size of the table

Extendible Hashing (Intuition) Situation: Bucket (primary page) becomes full. Why not re-organize file by doubling # of buckets? – Reading and writing all pages is expensive! – Idea: Use directory of pointers to buckets, double # of buckets by doubling the directory, splitting just the bucket that overflowed! – Directory much smaller than file, so doubling it is much cheaper. Only one page of data entries is split. No overflow page! – Trick lies in how hash function is adjusted!

Example Directory is array of size 4. To find bucket for r, take last `global depth’ # bits of h(r); we denote r by h(r). – If h(r) = 5 = binary 101, it is in bucket pointed to by 01. Insert : If bucket is full, split it ( allocate new page, re-distribute ). If necessary, double the directory. (As we will see, splitting a bucket does not always require doubling; we can tell by comparing global depth with local depth for the split bucket.) 13* LOCAL DEPTH GLOBAL DEPTH DIRECTORY Bucket A Bucket B Bucket C Bucket D DATA PAGES 10* 1*21* 4*12*32* 16* 15*7*19* 5*

Insert h(r) = 6 (The Easy Case) 13* LOCAL DEPTH GLOBAL DEPTH DIRECTORY Bucket A Bucket B Bucket C Bucket D DATA PAGES 10* 1*21* 4*12*32* 16* 15*7*19* 5* 6 = binary * LOCAL DEPTH GLOBAL DEPTH DIRECTORY Bucket A Bucket B Bucket C Bucket D DATA PAGES 10* 1*21* 4*12*32* 16* 15*7*19* 5* 6*

Insert h(r) = 20 (Causes Doubling) 20* LOCAL DEPTH 2 2 DIRECTORY GLOBAL DEPTH Bucket A Bucket B Bucket C Bucket D Bucket A2 (`split image' of Bucket A) 1* 5* 21* 13* 32* 16* 10* 15*7*19* 4*12* 13* LOCAL DEPTH GLOBAL DEPTH DIRECTORY Bucket A Bucket B Bucket C Bucket D DATA PAGES 10* 1*21* 4*12*32* 16* 15*7*19* 5* 20 = binary 10100

Insert h(r)=20 (Causes Doubling) 19* DIRECTORY Bucket A Bucket B Bucket C Bucket D Bucket A2 (`split image' of Bucket A) 32* 1*5*21*13* 16* 10* 15* 7* 4* 20* 12* LOCAL DEPTH GLOBAL DEPTH 20* LOCAL DEPTH 2 2 DIRECTORY GLOBAL DEPTH Bucket A Bucket B Bucket C Bucket D Bucket A2 (`split image' of Bucket A) 1* 5* 21* 13* 32* 16* 10* 15*7*19* 4*12* 20 = binary 10100

Points to Note 20 = binary Last 2 bits (00) tell us r belongs in A or A2. Last 3 bits needed to tell which. – Global depth of directory: Max # of bits needed to tell which bucket an entry belongs to. – Local depth of a bucket: # of bits used to determine if an entry belongs to this bucket. When does bucket split cause directory doubling? – Before insert, local depth of bucket = global depth. Insert causes local depth to become > global depth; directory is doubled by copying it over and `fixing’ pointer to split image page. (Use of least significant bits enables efficient doubling via copying of directory!)

Directory Doubling Why use least significant bits in directory? ó Allows for doubling via copying! vs * 6 = * 6 = Least SignificantMost Significant

Comments on Extendible Hashing If directory fits in memory, equality search answered with one disk access; else two. – 100MB file, 100 bytes/rec, 4K pages contains 1,000,000 records (as data entries) and 25,000 directory elements; chances are high that directory will fit in memory. – Directory grows in spurts, and, if the distribution of hash values is skewed, directory can grow large. Delete: If removal of data entry makes bucket empty, can be merged with `split image’. If each directory element points to same bucket as its split image, we can halve directory (this is rare in practice).

Extendable Hashing vs. Other Schemes Benefits of extendable hashing: –Hash performance does not degrade with growth of file –Minimal space overhead Disadvantages of extendable hashing –Extra level of indirection to find desired record –Bucket address table may itself become very big (larger than memory) Need a tree structure to locate desired record in the structure! –Changing size of bucket address table is an expensive operation Linear hashing is an alternative mechanism which avoids these disadvantages at the possible cost of more bucket overflows

Linear Hashing This is another dynamic hashing scheme, an alternative to Extendible Hashing. LH handles the problem of long overflow chains without using a directory. Idea: Use a family of hash functions h 0, h 1, h 2,... – h i (key) = h(key) mod(2 i N); N = initial # buckets – h is some hash function (range is not 0 to N-1) – If N = 2 d0, for some d0, h i consists of applying h and looking at the last di bits, where di = d0 + i. – h i+1 doubles the range of h i (similar to directory doubling)

Linear Hashing (Contd.) Directory avoided in LH by using overflow pages, and choosing bucket to split round-robin. – Splitting proceeds in `rounds’. Round ends when all N R initial (for round R) buckets are split. Buckets 0 to Next-1 have been split; Next to N R yet to be split. – Current round number is Level. – Search: To find bucket for data entry r, find h Level (r): If h Level (r) in range `Next to N R ’, r belongs here. Else, r could belong to bucket h Level (r) or bucket h Level (r) + N R ; must apply h Level+1 (r) to find out.

Linear Hashing (background) 2 4*12*32* 16* 3 4*12*20* 3 32* 16* We have seen what it means to split a bucket… 2 4*12*32* 16* 2 4*12*32* 16* 2 20* We have seen what it means to add an overflow page to a bucket… Insert 20 Before After Before After

Linear Hashing (background) 3 4*12*20* 3 32* 16* 2 4*12*32* 16* 2 20* It is meaningful to split a bucket with its overflow… Insert 20 After Before Note that as before, the number of bits pointing to the bucket must increase…

13* 10* 1*21* 4*12*32* 15*7*19* 5* 6* 2*14* Next Bucket to be split Stop when you get here 13*1*21* 32* 15*7*19* 5* 6* 14* Next Bucket to be split Stop when you get here 10* 2* Because {6 and 14}, and {10 and 2} differ in the 3 rd bit. Why split the first bucket, and overflow the {10, 6, 2, 14} bucket? 4*12* A new “round” begins

13*1*21* 32* 15*7*19* 5* 6* 14* Next Bucket to be split Stop when you get here xx* x* 4*12* g*h* f* q* 13*1*21* 32* 15*7*19* 5* 6* 14* Next Bucket to be split Stop when you get here h* d* 4*12* g*h* f* q* p*t* g* A “round” is about to end A new “round” begins

Overview of LH File In the middle of a round. Level h Buckets that existed at the beginning of this round: this is the range of Next Bucket to be split of other buckets) in this round Level hsearch key value) ( )( Buckets split in this round: If is in this range, must use h Level+1 `split image' bucket. to decide if entry is in created (through splitting `split image' buckets:

Level h Next Bucket to be split Level h Next Bucket to be split Level h Next Bucket to be split

Linear Hashing (Contd.) Insert: Find bucket by applying h Level / h Level+1 : – If bucket to insert into is full: Add overflow page and insert data entry. (Maybe) Split Next bucket and increment Next. Can choose any criterion to `trigger’ split. Since buckets are split round-robin, long overflow chains don’t develop! Doubling of directory in Extendible Hashing is similar; switching of hash functions is implicit in how the # of bits examined is increased.

Example of Linear Hashing On split, h Level+1 is used to re-distribute entries. 0 h h 1 ( This info is for illustration only!) Level=0, N= (The actual contents of the linear hashed file) Next=0 PRIMARY PAGES Data entry r with h(r)=5 Primary bucket page 44* 36* 32* 25* 9*5* 14*18* 10* 30* 31*35* 11* 7* 0 h h 1 Level= Next=1 PRIMARY PAGES 44* 36* 32* 25* 9*5* 14*18* 10* 30* 31*35* 11* 7* OVERFLOW PAGES 43*

Example: End of a Round 0 h h 1 22* Next= Level=0 PRIMARY PAGES OVERFLOW PAGES 32* 9* 5* 14* 25* 66* 10* 18* 34* 35*31* 7* 11* 43* 44*36* 37*29* 30* 0 h h 1 37* Next=0 Level= PRIMARY PAGES OVERFLOW PAGES 11 32* 9*25* 66* 18* 10* 34* 35* 11* 44* 36* 5* 29* 43* 14* 30* 22* 31*7* 50*

LH Described as a Variant of EH The two schemes are actually quite similar: – Begin with an EH index where directory has N elements. – Use overflow pages, split buckets round-robin. – First split is at bucket 0. (Imagine directory being doubled at this point.) But elements,,... are the same. So, need only create directory element N, which differs from 0, now. When bucket 1 splits, create directory element N+1, etc. So, directory can double gradually. Also, primary bucket pages are created in order. If they are allocated in sequence too (so that finding i’th is easy), we actually don’t need a directory! Voila, LH.

Comparison of Ordered Indexing (Trees) and Hashing Cost of periodic re-organization Relative frequency of insertions and deletions Is it desirable to optimize average access time at the expense of worst-case access time? Expected type of queries: –Hashing is generally better at retrieving records having a specified value of the key. –If range queries are common, ordered indices are to be preferred.

The red dotted slides that follow contain a nice worked example of extendible hashing. Starting with an empty database…

General Extendable Hash Structure In this structure, i 2 = i 3 = i, whereas i 1 = i – 1

Use of Extendable Hash Structure: Example Initial Hash structure, bucket size = 2

Example (Cont.) Hash structure after insertion of one Brighton and two Downtown records

Example (Cont.) Hash structure after insertion of Mianus record

Example (Cont.) Hash structure after insertion of three Perryridge records

Example (Cont.) Hash structure after insertion of Redwood and Round Hill records