1 / 14

6.830 Lecture 7

6.830 Lecture 7. 2/27/2013 Extensible Hashing, B+Trees , Buffer Pool Management. Hash Index. n buckets, on n disk pages Disk page 1 … Disk Page n. (‘ sam ’, 10k, …) (‘ joe ’, 20k, …). H(f1). e.g., H(x) = x mod n. Issues How big to make table? If we get it wrong, either

cutter
Download Presentation

6.830 Lecture 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 6.830 Lecture 7 2/27/2013 Extensible Hashing, B+Trees, Buffer Pool Management

  2. Hash Index n buckets, on n disk pages Disk page 1 … Disk Page n (‘sam’, 10k, …) (‘joe’, 20k, …) H(f1) e.g., H(x) = x mod n Issues How big to make table? If we get it wrong, either waste space, or end up with long overflow chains, or have to rehash

  3. Extensible Hashing • Create a family of hash tables parameterized by k Hk(x) = H(x) mod 2k • Start with k = 1 (2 hash buckets) • Use a directory structure to keep track of which bucket (page) each hash value maps to • When a bucket overflows, increment k (if needed), create a new bucket, rehash keys in overflowing bucket, and update directory

  4. Example Directory k=1 Hash Table Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  5. Example Directory k=1 Hash Table 0 0 mod 2 = 0 Hk(x) = x mod 2^k Insert records with keys 0, 0, 2, 3, 2

  6. Example Directory k=1 Hash Table 0 mod 2 = 0 Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  7. Example Directory k=1 Hash Table 2 mod 2 = 0 Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  8. Example Directory k=1 Hash Table 3 mod 2 = 1 Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  9. Example Directory k=1 Hash Table - FULL! 2 mod 2 = 0 Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  10. Example Directory k=1 2 Hash Table Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  11. Example Directory k=1 2 Hash Table Allocate new page! Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  12. Example Directory k=1 2 Hash Table Rehash Only allocate 1 new page! Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  13. Example Directory k=1 2 Hash Table 2mod 4 = 2 Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

  14. Example Directory k=1 2 Hash Table 2mod 4 = 2 Extra bookkeeping needed to keep track of fact that pages 0/2 have split and page 1 hasn’t Hk(x) = x mod k Insert records with keys 0, 0, 2, 3, 2

More Related