Documentation

mmap_manager

Memory-mapped array management for Context Fabric.

Classes

class

MmapManager

Manages memory-mapped numpy arrays for a corpus.

Manages memory-mapped numpy arrays for a corpus. Provides lazy loading and shared access to corpus data. Parameters ---------- cfm_path : Path Path to .cfm/{version}/ directory

Attributes

NameTypeDescription
_arraysdict[(str, NDArray[Any])]
_metadict[(str, Any)] | None
cfm_path
max_nodeint
max_slotint
metadict[(str, Any)]Load and cache corpus metadata.
node_typeslist[str]
slot_typestr

Methods

__init__(self, cfm_path: Path | str) None

Initialize manager for a .cfm directory.

Parameters
  • cfm_path: Path | str
close(self) None

Release all memory mappings.

exists(self) bool

Check if the .cfm directory exists and has metadata.

get_array(self, path_parts: str = ()) NDArray[Any]

Get a memory-mapped array, loading lazily.

Parameters
  • path_parts: str= ()
get_csr(self, path_parts: str = ()) CSRArray

Get CSR array pair.

Parameters
  • path_parts: str= ()
get_json(self, path_parts: str = ()) Any

Load a JSON metadata file.

Parameters
  • path_parts: str= ()
get_string_pool(self, feature_name: str) StringPool

Get string pool for a string-valued feature.

Parameters
  • feature_name: str