Skip to content

Commit

Permalink
chg: [Bloom filter] a new option added for non-hashlookup BF
Browse files Browse the repository at this point in the history
A new option has been added `--bloomfilters-lower-case` to
support now standard Bloom filter.

Based on discussion from pull-request #15
  • Loading branch information
adulau committed Sep 20, 2023
1 parent a00af79 commit d0410cd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bin/hashlookup-analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@
parser.add_argument(
"--bloomfilters",
nargs='+',
help="Space separated list of filenames of bloomfilters in DCSO bloomfilter format.",
help="Space separated list of filenames of bloomfilters in DCSO bloomfilter format. Hashlookup default format is used which SHA-1 in hexadecimal representation in upper case.",
default=None,
)
parser.add_argument(
"--bloomfilters-lower-case",
action="store_true",
help="If entries in the Bloom filter are expeceted to be lower case. Default is False.",
default=False,
)
args = parser.parse_args()

if args.bloomfilters is not None:
Expand Down Expand Up @@ -120,7 +126,11 @@ def lookup(value=None):

if args.bloomfilters is not None:
for bf in bfs:
if value.encode() in bf['bf']:
if args.bloomfilters_lower_case:
v = value.encode().lower()
else:
v = value.encode()
if v in bf['bf']:
ret = {}
ret['SHA-1'] = value
ret['source'] = bf['bloomfilter_source']
Expand Down

0 comments on commit d0410cd

Please sign in to comment.