OppoBloomFilter
This class implements the OppoBloomFilter, as proposed in the linked GitHub repository and blog post. It provides functionality related to this specific type of filter, likely for membership testing or similar data structure operations.
Methods
getIndex()
@classmethod
def getIndex(
id: []byte
) - > int32
Calculates the index for a given ID within the filter's internal array. This method is used internally to determine where an ID would be stored or checked.
Parameters
| Name | Type | Description |
|---|---|---|
| id | []byte | The byte slice representing the unique identifier for which to calculate the index. |
Returns
| Type | Description |
|---|---|
int32 | The calculated index as an integer. |
Add()
@classmethod
def Add(
_: context.Context,
id: []byte
) - > bool
Adds an ID to the OppoBloomFilter. This method marks the presence of an ID, ensuring that subsequent 'Contains' calls for the same ID will return true.
Parameters
| Name | Type | Description |
|---|---|---|
| _ | context.Context | The context for the operation, allowing for cancellation and timeouts. |
| id | []byte | The byte slice representing the unique identifier to be added to the filter. |
Returns
| Type | Description |
|---|---|
bool | A boolean indicating whether the ID was successfully added (true) or if it was already present (false). |
Contains()
@classmethod
def Contains(
_: context.Context,
id: []byte
) - > bool
Checks if an ID is present in the OppoBloomFilter. This method determines if an ID has been previously added to the filter.
Parameters
| Name | Type | Description |
|---|---|---|
| _ | context.Context | The context for the operation, allowing for cancellation and timeouts. |
| id | []byte | The byte slice representing the unique identifier to check for existence in the filter. |
Returns
| Type | Description |
|---|---|
bool | A boolean indicating whether the ID is present in the filter (true) or not (false). |