1313/* *
1414 * Directory page format:
1515 * --------------------------------------------------------------------------------------
16- * | MaxSize (4) | GlobalDepth (4) | LocalDepths (512) | BucketPageIds(2048) | Free(1528)
16+ * | MaxDepth (4) | GlobalDepth (4) | LocalDepths (512) | BucketPageIds(2048) | Free(1528)
1717 * --------------------------------------------------------------------------------------
1818 */
1919
@@ -39,7 +39,8 @@ static constexpr uint64_t HTABLE_DIRECTORY_PAGE_METADATA_SIZE = sizeof(uint32_t)
3939 * Extending the directory implementation to span multiple pages would be a meaningful improvement to the
4040 * implementation.
4141 */
42- static constexpr uint64_t HTABLE_DIRECTORY_ARRAY_SIZE = 512 ;
42+ static constexpr uint64_t HTABLE_DIRECTORY_MAX_DEPTH = 9 ;
43+ static constexpr uint64_t HTABLE_DIRECTORY_ARRAY_SIZE = 1 << HTABLE_DIRECTORY_MAX_DEPTH;
4344
4445/* *
4546 * Directory Page for extendible hash table.
@@ -53,17 +54,17 @@ class ExtendibleHTableDirectoryPage {
5354 /* *
5455 * After creating a new directory page from buffer pool, must call initialize
5556 * method to set default values
56- * @param max_size Max size of the array in the directory page
57+ * @param max_depth Max depth in the directory page
5758 */
58- void Init (int max_size = HTABLE_DIRECTORY_ARRAY_SIZE );
59+ void Init (uint32_t max_depth = HTABLE_DIRECTORY_MAX_DEPTH );
5960
6061 /* *
61- * Get the bucket page id that the key is hashed to
62+ * Get the bucket index that the key is hashed to
6263 *
6364 * @param hash the hash of the key
64- * @return bucket page_id current key is hashed to
65+ * @return bucket index current key is hashed to
6566 */
66- auto HashToBucketPageId (uint32_t hash) -> page_id_t ;
67+ auto HashToBucketIndex (uint32_t hash) -> uint32_t ;
6768
6869 /* *
6970 * Lookup a bucket page using a directory index
@@ -89,31 +90,6 @@ class ExtendibleHTableDirectoryPage {
8990 **/
9091 auto GetSplitImageIndex (uint32_t bucket_idx) -> uint32_t;
9192
92- /* *
93- * GetGlobalDepthMask - returns a mask of global_depth 1's and the rest 0's.
94- *
95- * In Extendible Hashing we map a key to a directory index
96- * using the following hash + mask function.
97- *
98- * DirectoryIndex = Hash(key) & GLOBAL_DEPTH_MASK
99- *
100- * where GLOBAL_DEPTH_MASK is a mask with exactly GLOBAL_DEPTH 1's from LSB
101- * upwards. For example, global depth 3 corresponds to 0x00000007 in a 32-bit
102- * representation.
103- *
104- * @return mask of global_depth 1's and the rest 0's (with 1's from LSB upwards)
105- */
106- auto GetGlobalDepthMask () -> uint32_t;
107-
108- /* *
109- * GetLocalDepthMask - same as global depth mask, except it
110- * uses the local depth of the bucket located at bucket_idx
111- *
112- * @param bucket_idx the index to use for looking up local depth
113- * @return mask of local 1's and the rest 0's (with 1's from LSB upwards)
114- */
115- auto GetLocalDepthMask (uint32_t bucket_idx) -> uint32_t;
116-
11793 /* *
11894 * Get the global depth of the hash table directory
11995 *
@@ -169,16 +145,6 @@ class ExtendibleHTableDirectoryPage {
169145 */
170146 void DecrLocalDepth (uint32_t bucket_idx);
171147
172- /* *
173- * Gets the high bit corresponding to the bucket's local depth.
174- * This is not the same as the bucket index itself. This method
175- * is helpful for finding the pair, or "split image", of a bucket.
176- *
177- * @param bucket_idx bucket index to lookup
178- * @return the high bit corresponding to the bucket's local depth
179- */
180- auto GetLocalHighBit (uint32_t bucket_idx) -> uint32_t;
181-
182148 /* *
183149 * VerifyIntegrity
184150 *
@@ -195,7 +161,7 @@ class ExtendibleHTableDirectoryPage {
195161 void PrintDirectory ();
196162
197163 private:
198- uint32_t max_size_ ;
164+ uint32_t max_depth_ __attribute__ ((__unused__)) ;
199165 uint32_t global_depth_;
200166 uint8_t local_depths_[HTABLE_DIRECTORY_ARRAY_SIZE];
201167 page_id_t bucket_page_ids_[HTABLE_DIRECTORY_ARRAY_SIZE];
0 commit comments