Skip to content

Instantly share code, notes, and snippets.

@kelvingakuo
Created November 26, 2021 19:34
Show Gist options
  • Save kelvingakuo/3da02a007286e0cf0f02c9e6e60b6cf2 to your computer and use it in GitHub Desktop.
Save kelvingakuo/3da02a007286e0cf0f02c9e6e60b6cf2 to your computer and use it in GitHub Desktop.
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