In file 'Scrapy_Redis_Bloomfilter/scrapyWithBloomfilter_demo/scrapyWithBloomfilter_demo/scrapy_redis/BloomfilterOnRedis.py', code lines of 33-42:
def isContains(self, str_input):
if not str_input:
return False
ret = True
name = self.key + str(int(str_input[0:2], 16) % self.blockNum)
for f in self.hashfunc:
loc = f.hash(str_input)
ret = ret & self.server.getbit(name, loc)
return ret
When getbit returns 0, it could tell the non-contains. So I think it'd be better to add 2 more code lines like this to speed up this function:
def isContains(self, str_input):
if not str_input:
return False
ret = True
name = self.key + str(int(str_input[0:2], 16) % self.blockNum)
for f in self.hashfunc:
loc = f.hash(str_input)
ret = ret & self.server.getbit(name, loc)
if not ret:
break
return ret
def isContains(self, str_input):
if not str_input:
return False
ret = True
name = self.key + str(int(str_input[0:2], 16) % self.blockNum)
for f in self.hashfunc:
loc = f.hash(str_input)
ret = self.server.getbit(name, loc)
if not ret:
break
return ret