Top Banner
Arch (A) Tented Arch (T) Whorl (W) Loop (U or R) The four main classes of fingerprin ts Loop (60%) Arch/Tented Arch (6%) Whorl (34%) Other (Less than 1%) (accidentals) Distribution of classes (Caucasian) Johannes Purkinje 1787-1869
51

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%)

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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%)

Arch (A) Tented Arch (T) Whorl (W) Loop (U or R)

The four mainclasses of fingerprints

Loop (60%)

Arch/Tented Arch (6%)

Whorl (34%)

Other (Less than 1%)(accidentals)

Distribution of classes (Caucasian) Johannes Purkinje

1787-1869

Page 2: 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%)

No Normal Class on Thursday!!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!

Page 3: 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%)

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 Thumb 2) R Index 3) R Middle 4) R Ring

85) R Little

6) L Thumb 7) L Index 8) L Middle 9) L Ring

110) L Little

8 + 1 1 + 1

9 2=

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 Henry1850-1931

Page 4: 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%)

The Henry Classification System IIThe Henry Classification System II

9 + 1 3 + 1

10 4=

1) R Thumb 2) R Index 3) R Middle 4) R Ring

8

5) R Little

6) L Thumb 7) L Index

2

8) L Middle 9) L Ring

110) L Little

1

4 + 1 1 + 1

5 2=

1) R Thumb 2) R Index 3) R Middle 4) R Ring 5) R Little

6) L Thumb

47) L Index 8) L Middle 9) 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

Page 5: 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%)

The Henry Classification System IIIThe 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 25 possible numerators. The same argument is holds for the denominator.

So the number of possible numerators times the number of possible denominators is 25 *

25 = 210 = 1024

Some of the 1024 “bins” in Scotland Yards Fingerprint Bureau during the 1950s

Page 6: 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%)
Page 7: 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%)

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

Page 8: 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%)

Static HashingStatic HashingWith hash based indexing, we assume that we have a function h, which tells us where to place any given record.

DataPage 1

DataPage 2

DataPage 3

DataPage N-1

DataPage N

h

:::

Page 9: 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%)

Static HashingStatic HashingThe 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).

Page 10: 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%)

Static HashingStatic HashingAs with ISAM, insertion can cause overflow. The solution is to create chains of overflow pages.

DataPage 1

DataPage 2

DataPage 3

DataPage N-1

DataPage N

h

:::

Overflow for 3

Page 11: 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%)

Note about NotationNote about NotationOur 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.

Page 12: 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%)

Hash FunctionsHash 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.

Page 13: 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%)

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

Page 14: 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%)

Deficiencies of Static HashingDeficiencies 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.

Page 15: 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%)

Deficiencies of Static HashingDeficiencies 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.

Page 16: 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%)

Hash IndicesHash 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.

Page 17: 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%)

Example of Hash IndexExample of Hash Index

h

Page 18: 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%)

Extendable Hashing (Formal)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 = 2i. 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 < 2i

• The number of buckets also changes dynamically due to coalescing and splitting of buckets.

Page 19: 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%)

Use of Extendable Hash Structure Use of Extendable Hash Structure (Formal)(Formal)

• Each bucket j stores a value ij; all the entries that point to the same bucket have the same values on the first ij bits.

• To locate the bucket containing search-key Kj:

1. Compute h(Kj) = 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 Kj – 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)

Page 20: 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%)

Updates in Extendable Hash StructureUpdates in Extendable Hash Structure (Formal)(Formal)

• If i > ij (more than one pointer to bucket j)

– allocate a new bucket z, and set ij and iz to the old ij -+ 1.

– 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 Kj and insert record in the bucket (further splitting is required if the bucket is still full)

• If i = ij (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 Kj

Now i > ij so use the first case above.

To split a bucket j when inserting record with search-key value Kj:

Page 21: 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%)

Updates in Extendable Hash Structure (Cont.) (Formal)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 ij and same ij –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

Page 22: 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%)

Extendible Hashing (Intuition)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!

Page 23: 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%)

ExampleExample

• 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*00

01

10

11

2

2

2

2

2

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*

Page 24: 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%)

Insert Insert hh(r) = 6 (The Easy Case)(r) = 6 (The Easy Case)

13*00

01

10

11

2

2

2

2

2

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 00110

13*00

01

10

11

2

2

2

2

2

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*

Page 25: 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%)

Insert Insert hh(r) = 20 (Causes Doubling)(r) = 20 (Causes Doubling)

20*

00

01

10

11

2 2

2

2

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*00

01

10

11

2

2

2

2

2

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

Page 26: 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%)

Insert Insert hh(r)=20 (Causes Doubling)(r)=20 (Causes Doubling)

19*

2

2

2

000

001

010

011

100

101

110

111

3

3

3DIRECTORY

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*

00

01

10

11

2 2

2

2

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

Page 27: 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%)

Points to NotePoints to Note• 20 = binary 10100. 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!)

Page 28: 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%)

Directory DoublingDirectory Doubling

00

01

10

11

2

Why use least significant bits in directory? Allows for doubling via copying!

000

001

010

011

3

100

101

110

111

vs.

0

1

1

6*6*

6*

6 = 110

00

10

01

11

2

3

0

1

1

6*6*

6*

6 = 110000

100

010

110

001

101

011

111

Least Significant Most Significant

Page 29: 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%)

Comments on Extendible HashingComments 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).

Page 30: 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%)
Page 31: 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%)

Extendable Hashing vs. Other SchemesExtendable 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

Page 32: 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%)

Linear HashingLinear 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 h0, h1, h2, ...– hi(key) = h(key) mod(2iN); N = initial # buckets

– h is some hash function (range is not 0 to N-1)

– If N = 2d0, for some d0, hi consists of applying h and looking at the last di bits, where di = d0 + i.

– hi+1 doubles the range of hi (similar to directory doubling)

Page 33: 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%)

Linear Hashing (Contd.)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 NR

initial (for round R) buckets are split. Buckets 0 to Next-1 have been split; Next to NR yet to be split.

– Current round number is Level.

– Search: To find bucket for data entry r, find hLevel(r):

• If hLevel(r) in range `Next to NR’ , r belongs here.

• Else, r could belong to bucket hLevel(r) or bucket hLevel(r) + NR; must apply hLevel+1(r) to find out.

Page 34: 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%)

Linear Hashing (background)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

Page 35: 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%)

Linear Hashing (background)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…

Page 36: 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%)

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 3rd bit.

Why split the first bucket, and overflow the {10, 6, 2, 14} bucket?

4* 12*

100010101010010101

A new “round” begins

Page 37: 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%)

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*

NextBucket 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

Page 38: 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%)

Overview of LH FileOverview of LH File

• In the middle of a round.

Levelh

Buckets that existed at thebeginning of this round:

this is the range of

NextBucket to be split

of other buckets) in this round

Levelh search key value )(

search key value )(

Buckets split in this round:If is in this range, must useh Level+1

`split image' bucket.to decide if entry is in

created (through splitting`split image' buckets:

Page 39: 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%)

Levelh

Next

Bucket to be split

Levelh Next

Bucket to be split

Levelh Next

Bucket to be split

Page 40: 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%)

Linear Hashing (Contd.)Linear Hashing (Contd.)

• Insert: Find bucket by applying hLevel / hLevel+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.

Page 41: 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%)

Example of Linear HashingExample of Linear Hashing

• On split, hLevel+1 is used to re-distribute entries.

0hh

1

(This infois for illustrationonly!)

Level=0, N=4

00

01

10

11

000

001

010

011

(The actual contentsof the linear hashedfile)

Next=0

PRIMARYPAGES

Data entry rwith h(r)=5

Primary bucket page

44* 36*32*

25*9* 5*

14* 18*10*30*

31*35* 11*7*

0hh

1

Level=0

00

01

10

11

000

001

010

011

Next=1

PRIMARYPAGES

44* 36*

32*

25*9* 5*

14* 18*10*30*

31*35* 11*7*

OVERFLOWPAGES

43*

00100

Page 42: 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%)

Example: End of a RoundExample: End of a Round

0hh1

22*

00

01

10

11

000

001

010

011

00100

Next=3

01

10

101

110

Level=0PRIMARYPAGES

OVERFLOWPAGES

32*

9*

5*

14*

25*

66* 10*18* 34*

35*31* 7* 11* 43*

44*36*

37*29*

30*

0hh1

37*

00

01

10

11

000

001

010

011

00100

10

101

110

Next=0

Level=1

111

11

PRIMARYPAGES

OVERFLOWPAGES

11

32*

9* 25*

66* 18* 10* 34*

35* 11*

44* 36*

5* 29*

43*

14* 30* 22*

31*7*

50*

Page 43: 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%)

LH Described as a Variant of EHLH 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 <1,N+1>, <2,N+2>, ... 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.

Page 44: 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%)

Comparison of Ordered Indexing (Trees) and Comparison of Ordered Indexing (Trees) and HashingHashing

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

Page 45: 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%)

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

Page 46: 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%)

General Extendable Hash StructureGeneral Extendable Hash Structure

In this structure, i2 = i3 = i, whereas i1 = i – 1

Page 47: 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%)

Use of Extendable Hash Structure: ExampleUse of Extendable Hash Structure: Example

Initial Hash structure, bucket size = 2

Page 48: 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%)

Example (Cont.)Example (Cont.)

• Hash structure after insertion of one Brighton and two Downtown records

Page 49: 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%)

Example (Cont.)Example (Cont.)

Hash structure after insertion of Mianus record

Page 50: 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%)

Example (Cont.)Example (Cont.)

Hash structure after insertion of three Perryridge records

Page 51: 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%)

Example (Cont.)Example (Cont.)

• Hash structure after insertion of Redwood and Round Hill records