Skip to content

Bloom filter improvement #607

Open
Open
@JeneaVranceanu

Description

@JeneaVranceanu

Here you can find an implementation of a bloom filter that could be used to implement a better version of bloom9.
Looks like this link is unsecured due to issues with SSL certificate so I copied the code snippet.

This is not certain but looks like we can try to follow this example and potentially improve performance of bloom filter calculation:

# external imports
import sha3

class LogBloom:

    def __init__(self):
        self.content = bytearray(256)


   def add(self, element):
       if not isinstance(element, bytes):
           raise ValueError('element must be bytes')
        h = sha3.keccak_256()
        h.update(element)
        z = h.digest()

        for j in range(3):
            c = j * 2
            v = int.from_bytes(z[c:c+2], byteorder='big')
            v &= 0x07ff
            m = 255 - int(v / 8)
            n = v % 8
            self.content[m] |= (1 << n)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions