Directory handling



next up previous
Next: Insert records Up: Internal Design Previous: Destroy index

Directory handling

Every bucket's primary page's PageId is stored in some DirPage. The PageId's of all the DirPage's are consecutive thanks to the method BufMgr::newPage which can allocate a run of pages. When the index is created, the number of the DirPage's initially needed is computed and a run of that number of pages is allocated. The PageId of the first page of this run is stored in the header page. As the file gets expanded, the directory may become full. Then its capacity is doubled by allocating a new run of pages which has twice number of pages of the old directory. All the information in the old directory is copied to the new directory and the old directory is destroyed. Conversely, if only half of the directory is used, then the capacity is reduced by one half in the similar way. The directory looks like a dynamic array in this way. The advantage of this design is that we only need to pin the DirPage that's used and only the PageId of the first DirPage needs to be stored in the header page. Since the expansion and contraction of directory rarely happen, the overhead is very limited.



Weiqing Huang
Sun May 14 16:22:27 CDT 1995