System method and computer program product for dynamically sizing hash tables
First Claim
1. A method for dynamically sizing a hash table in a processor, comprising the steps of:
- (1) allocating a hash table having a number n of hash buckets;
(2) hashing records into the hash table;
(3) re-sizing the hash table when an actual number of records in the hash table exceeds a limit; and
(4) re-hashing the records in the hash table after the hash table is re-sized using a lazy re-hashinz algorithm wherein a logical pointer is associated with a new hash bucket and the logical pointer points to a pre-existing hash bucket that potentially contains records that belong in the new hash bucket.
15 Assignments
0 Petitions
Accused Products
Abstract
The present invention is a system, method, and computer program product for dynamically sizing a hash table when the average number of records per bucket in the hash table exceeds a maximum average number of records per bucket. In one embodiment, the hash table employs a modulo hashing function. In a second embodiment, the number of buckets is grown by a multiple of the previous number of buckets and records are re-hashed using a lazy re-hashing modulo algorithm that re-hashes records in a hash bucket only when those records are searched. In the second embodiment, when a hash table is re-sized, each new bucket is provided with a logical back pointer, or index, to a pre-existing bucket that potentially contains records that belong in the new bucket. When a search is directed at a new bucket, the logical back pointer, or index, directs the search to a pre-existing bucket. When a search of a pre-existing bucket finds a data record that belongs in a new bucket, the record is moved to the new bucket. When there are no more records in a pre-existing bucket that belong in a new bucket, the logical back pointer from the new bucket to the pre-existing bucket is removed. Preferably, the logical back pointer is stored in the bucket where a regular pointer would normally be stored so that no extra space is needed.
155 Citations
24 Claims
-
1. A method for dynamically sizing a hash table in a processor, comprising the steps of:
-
(1) allocating a hash table having a number n of hash buckets; (2) hashing records into the hash table; (3) re-sizing the hash table when an actual number of records in the hash table exceeds a limit; and (4) re-hashing the records in the hash table after the hash table is re-sized using a lazy re-hashinz algorithm wherein a logical pointer is associated with a new hash bucket and the logical pointer points to a pre-existing hash bucket that potentially contains records that belong in the new hash bucket. - View Dependent Claims (2, 3, 4, 5, 6, 7, 22)
-
-
8. A system for dynamically sizing a hash table of records in a processor, comprising:
-
a hashing function that generates a hash table having a number of buckets n and that hashes records into the buckets based on a key value associated with each record; a re-sizing module that dynamically re-sizes the hash table when an actual number of records in the hash table exceeds a limit; and a lazy re-hashing function that re-hashes the records using a lazy re-hashing algorithm, wherein a logical pointer is associated with a new hash bucket and the logical pointer points to a pre-existing hash bucket that potentially contains records that belong in the new hash bucket. - View Dependent Claims (9, 10, 11, 12, 13, 14, 23)
-
-
15. A computer program product comprising a computer useable medium having computer program logic stored therein, said computer program logic for enabling a computer to dynamically re-size a hash table, wherein said computer program logic comprises:
-
means for enabling the computer to allocate a hash table having a number n of hash buckets; means for enabling the computer to hash records into the hash table; means for enabling the computer to re-size the hash table when an actual number of records in the hash table exceeds a limit; and means for enabling the computer to re-hash the records in the hash table after the hash table is re-sized using a lazv re-hashing algorithm, wherein a logical pointer is associated with a new hash bucket and the logical pointer points to a pre-existing hash bucket that potentially contains records that belong in the new hash bucket. - View Dependent Claims (16, 17, 18, 19, 20, 21, 24)
-
Specification