0% found this document useful (0 votes)
34 views

File Org Part 3

File Organization explained
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

File Org Part 3

File Organization explained
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Hashed Files

Dynamic and Extendible Hashing Techniques

Static External Hashing

Hashing techniques are adapted to allow the dynamic growth


and shrinking of the number of file records.

Dynamic and Extendible Hashing Techniques


These techniques include the following:
Dynamic hashing
Extendible hashing

Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

Dynamic and Extendible Hashing Techniques

The directories can be stored on disk. They expand or shrink


dynamically.

Both dynamic and extendible hashing use the binary


representation of the hash value h(K) in order to access a
directory.

Directory entries point to the disk blocks that contain the stored
records.

In dynamic hashing, the directory is a binary tree.


d
In extendible hashing, the directory is an array of size 2 where d
is called the global depth.

An insertion in a disk block that is full causes the block to split


into two blocks and the records are redistributed among the two
blocks.
The directory is updated appropriately.
Dynamic and extendible hashing do not require an overflow
area.

Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

Dynamic Hashing

Dynamic Hashing

The number of buckets are not fixed as regular hashing, but

Place the records in a bucket according to the last K binary


digits in the hash number.

grows or diminishes as needed.


8
17
25
34
50
28
5
55

Internal nodes: Guide the search; each has a left pointer


corresponding to a 0 bit and a right pointer corresponding to a
1 bit.
Leaf nodes: Hold a pointer to a bucket-a bucket address.

=
=
=
=
=
=
=
=

001,000
010,001
011,001
100,010
110,010
011,100
000,101
110,111

Copyright , 2016 B. Seyed Abbassi

Dynamic Hashing

Dynamic Hashing

8
17
25
34
50
28
5
55

If a bucket overflows, it is split into two, and the records are


distributed based on next significant bit in their hash value.
Map Key 52 to hash file:

=
=
=
=
=
=
=
=

001,000
010,001
011,001
100,010
110,010
011,100
000,101
110,111

52 =
0

Copyright , 2016 B. Seyed Abbassi

0
0

17

25
28

110,100

34

50
55

17

25
28

34

50
55
Map Key 52

Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

Dynamic Hashing

Extendible Hashing

50 = 110,010
55 = 110,111
52 = 110,100

This technique alleviates the problem of collision the same as


dynamic hashing.
0

17

25

34

In this hash technique, a different type of directory (an array of


k
2 bucket addresses is maintained, where k is called Global
depth of the directory.

28

50

55
52

Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

Extendible Hashing

Extendible Hashing

Place the records in a bucket according to the last K binary


digits (K = Depth) in the hash number.

Stored file has a directory.

8
17
25
34
50
28
5
55

=
=
=
=
=
=
=
=

001,000
010,001
011,001
100,010
110,010
011,100
000,101
110,111

d
Directory has a header, containing Depth of Directory, with 2
pointers.

000 5

The pointers are pointers to buckets or data pages.

001 8
010 17
011 25

28

100 34
101
110 50

55

111
Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

After Split

Extendible Hashing
Directory

Directory

00

000
001

01

010
011

10

100
101

11

110
111

Map several records with keys 00XXX

Map a new key 10XXX


Copyright , 2016 B. Seyed Abbassi

After Split (000 & 001)

Directory
000
001
010
011
100
101
110
111

Note: Values of the hash field (primary key) should be unique.


Copyright , 2016 B. Seyed Abbassi

Copyright , 2016 B. Seyed Abbassi

You might also like