Weakness of the Extensible Hashing technique
The Linear Hashing technique was
proposed to
address this weakenss
Overview of the Linear Hashing technique
Linear Hashing is
based on
Extensible Hashing !!!
Linear Hashing uses a
clever
logical hash index → physical
hash index
mapping function
Modifying the
logical index → physical index
of the Extensible Hashing technique
Recall the
bucket size doubling technique
of Extensible hashing:
Suppose
we increase i = i + 1 and
double the
logical hash bucket size....
Modifying the
logical index → physical index
of the Extensible Hashing technique
We can fix the
hash index using
this logical index →
physical index mapping:
Modifying the
logical index → physical index
of the Extensible Hashing technique
Take a good look at the
logical index → physical index
map:
Can you find (think of)
a function that
you can use
to perform the
same mapping operation ?
(Reason::
if you can find such a
function, then you
don't need to
store the map
using array elements !!)
Modifying the
logical index → physical index
of the Extensible Hashing technique
If we can find such
a mapping function:
We
don't need to
store the map
using array elements
in order to
double the
logical hash table size !!
Modifying the
logical index → physical index
of the Extensible Hashing technique
We can map the
new array index
to an existing array index:
If
hash index x ≤
011 (binary),
we use the block pointer in
the logical bucket[ x
]
If
hash index x ≥
100 (binary),
we use the block pointer in
the
logical bucket[
suffix-1(x)
]
where:
suffix-1(x)
=
x − 2⌊log(x)⌋
What does the suffix-1( x ) do:
Suffix-1(x)
removes
the
leading 1 bit from
the binary number x
My terminology: "virtual" hash bucket
"Virtual" hash bucket:
For a "virtual" hash bucket x,
we use
suffix-1(x)
to map
to a (real)
logical hash bucket:
How to use Suffix-1( ) function
to double the
logical hash table size
Initial state:
(the hash function uses
(i − 1) bits )
How to use Suffix-1( ) function
to double the
logical hash table size
Suppose we
double the
hash index range
(the hash function uses
i bits)
How to use Suffix-1( ) function
to double the
logical hash table size
If x is
a real
logical hash bucket:
use
LogicalBucket[x]
to
find physical hash bucket
How to use Suffix-1( ) function
to double the
logical hash table size
If x is
a "virtual"
logical hash bucket:
use
LogicalBucket[Suffix-1(x)]
to
find physical hash bucket
How to
increase the
physical hash table
gradually using the new mapping technique
Initial state:
How to
increase the
physical hash table
gradually using the new mapping technique
After
doubling the
logical hash table
(i.e.: increase the parameter i):
How to
increase the
physical hash table
gradually using the new mapping technique
We can add a
new
physical bucket
(100)
and
adjust the
logical → physical map:
Problem:
the keys that
hashes to
100
can no longer be found !!
How to
increase the
physical hash table
gradually using the new mapping technique
How to fix the
problem:
re-hash the keys
in bucket[Suffix-1(x)]
How to
tell if
a (logical) hash index is
a real or virtual
logical hash bicket ?
❮
❯