Skip to content

Commit

Permalink
improve validation of quotient filter metadata bits (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust authored Dec 20, 2024
1 parent f29e1dc commit 92d9984
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions probables/quotientfilter/quotientfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,24 @@ def print(self, file: TextIO = sys.stdout):
file=file,
)

def validate_metadata(self):
"""check for invalid bit settings"""
def validate_metadata(self, verbose=False) -> bool:
"""Check for invalid bit settings, per the wikipedia documentation
Args:
verbose (str): Print which index in the quotient filter failed
Returns:
bool: True if the metadata bits are all passing; False otherwise"""
is_valid = True
for i in range(self._size):
if self._is_occupied[i] == 0 and self._is_continuation == 1 and self._is_shifted == 0:
print(f"Row failed: {i}")
if verbose:
print(f"Row failed: {i}")
is_valid = False
if self._is_occupied[i] == 1 and self._is_continuation == 1 and self._is_shifted == 0:
print(f"Row failed: {i}")
if verbose:
print(f"Row failed: {i}")
is_valid = False
return is_valid

def _element_is(self, idx):
is_a = "Continuation"
Expand Down

0 comments on commit 92d9984

Please sign in to comment.