Created
November 26, 2021 19:34
-
-
Save kelvingakuo/3da02a007286e0cf0f02c9e6e60b6cf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_hash_index(self) -> None: | |
""" Creates a hash index of our data based on the column | |
""" | |
self.hash_table = dict() | |
for row in self.table: | |
hsh, buck = self.hash_function(row[self.on]) | |
if(self.hash_table.get(buck, None) is None): | |
# Empty bucket, insert TID | |
self.hash_table[buck] = [] | |
self.hash_table[buck].append({"hash_code": hsh, "row_tid": row["TID"]}) | |
else: | |
# Perform chaining | |
val = {"hash_code": hsh, "row_tid": row["TID"]} | |
current_vals = self.hash_table[buck] | |
current_vals.append(val) | |
self.hash_table[buck] = current_vals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment