Hash( key ) = RandomNumGen( key ) % B
|
where:
|
Hash( key ) = RandomNumGen( key ) % 2i |
Graphically:
|
|
|
|
Graphically:
|
|
Graphically:
|
|
Graphically:
|
|
|
|
|
|
|
|
|
|
|
Parameter: i = # bits used in RandomNumGen
Insert( x, recordPtr(x) )
{
k = h(x); // Genenral Hash function value
j = k % 2i ; // Extensible hash function value
Read disk block at bucket[j] (1 block) into memory;
if ( bucket[j] block has space for a search key )
{
Insert (x, recordPtr(x) ) into the block;
Write block back to disk;
return; // Done !
}
/* -------------------------------------
bucket[j] disk block is full
------------------------------------- */
Let i' = integer label of physical bucket[j] block;
/* ========================================================
Check if we need to increase the logical hash table size
========================================================= */
if ( i' == i )
{
Double the logical hash table;
i = i + 1; // We use 1 more bit to hash
Before:
|
|
|
Note:
|
|
|
|
|
|
Better solution:
|