ahvn.klengine.scan_engine module

class ahvn.klengine.scan_engine.ScanKLEngine(storage, name=None, condition=None, *args, **kwargs)[source]

Bases: BaseKLEngine

A brute-force scan KLEngine implementation with zero storage overhead.

This engine performs search by scanning through the entire attached KLStore and using eval_filter on each KL to find matches. It is always inplace and supports all kinds of KLStores.

This is the simplest possible search engine - no indexing, no optimization, just linear scan. Useful for small datasets or as a fallback.

Search Methods:

_search(topk, offset, include, **kwargs): Perform brute-force scan using eval_filter.

Abstract Methods (inherited from BaseKLEngine):

_upsert(kl): No-op (always inplace). _remove(key): No-op (always inplace). _clear(): No-op (always inplace).

Parameters:
inplace: bool = True
recoverable: bool = True
__init__(storage, name=None, condition=None, *args, **kwargs)[source]

Initialize the ScanKLEngine.

Parameters:
  • storage (BaseKLStore) – attach ScanKLEngine to a BaseKLStore (required).

  • name (Optional[str]) – Name of the KLEngine instance. If None, defaults to “{storage.name}_scan_idx”.

  • condition (Optional[Callable]) – Optional upsert/insert condition to apply to the KLEngine. KLs that do not satisfy the condition will be ignored. If None, all KLs are accepted.

  • *args – Additional positional arguments passed to ScanKLEngine.

  • **kwargs – Additional keyword arguments passed to ScanKLEngine.

__len__()[source]

Return the number of KLs in the storage.

Returns:

The number of KLs in the storage.

Return type:

int

__iter__()[source]

Iterate over all KLs in the storage.