Skip to main content

Filter

This interface defines a filter that can check for the presence of an ID and add new IDs. It provides methods to determine if an ID has been seen previously and to add an ID, potentially evicting an older item.

Methods


Contains()

@classmethod
def Contains(
ctx: context.Context,
id: []byte
) - > bool

Contains returns a True if the id was previously seen or false otherwise It may return a false, even if a item may have previously occurred.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and timeouts.
id[]byteThe identifier to check for previous occurrence in the filter.

Returns

TypeDescription
boolTrue if the id was previously seen, False otherwise. Note that it may return False even if an item has occurred.

Add()

@classmethod
def Add(
ctx: context.Context,
id: []byte
) - > bool

Adds the element id to the Filter and returns if a previous object was evicted in the process

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and timeouts.
id[]byteThe identifier to add to the filter.

Returns

TypeDescription
boolTrue if an existing object was evicted from the filter during the add operation, False otherwise.