Documentation

computed

# Pre-computed data components

In order to make the API work, CF prepares some data and saves it in quick-load format. Most of this data are the features, but there is some extra data needed for the special functions of the `cfabric.parameters.WARP` features and the `cfabric.locality.Locality` API.

Normally, you do not use this data, but since it is there, it might be valuable, so we have made it accessible in the `cfabric.computed.Computeds`-API.

!!! explanation "Pre-computed data storage" Pre-computed data is stored in a `.cfm` directory (Context Fabric Mmap format) inside the directory where the `otype` feature is encountered.

The `.cfm` format uses memory-mapped numpy arrays for: - Shared memory across async workers - Reduced memory footprint - Near-zero startup time after initial compilation

Use `CF.compile()` to generate the `.cfm` directory from `.tf` source files. Subsequent calls to `CF.load()` will automatically use the compiled format.

Classes

class

BoundaryComputed

(Computed)

C.boundary: first/last slot boundary data.

class

Computed

Provides access to pre-computed data.

Provides access to pre-computed data. For component `ccc` it is the result of `C.ccc` or `Cs('ccc')`.

Attributes

NameTypeDescription
api
data

Methods

__init__(self, api: Api, data: Any) None
Parameters
  • api: Api
  • data: Any
class

Computeds

class

LevDownComputed

(Computed)

C.levDown: embeddees of each node.

C.levDown: embeddees of each node. Supports CSRArray backend for mmap. Only for non-slot nodes, so index is n - maxSlot - 1. For faster embedding queries, call `preload()` to cache data in RAM. This trades ~40MB memory for 3x faster `[[` relation queries.

Attributes

NameTypeDescription
is_cachedboolReturn True if data is cached in RAM.

Methods

preload(self) None

Preload embedding data into RAM for faster queries.

release(self) None

Release cached RAM, returning to memory-mapped access.

class

LevUpComputed

(Computed)

C.levUp: embedders of each node.

C.levUp: embedders of each node. Supports CSRArray backend for mmap. For faster embedding queries, call `preload()` to cache data in RAM. This trades ~60MB memory for 3x faster `]]` relation queries.

Attributes

NameTypeDescription
is_cachedboolReturn True if data is cached in RAM.

Methods

preload(self) None

Preload embedding data into RAM for faster queries.

release(self) None

Release cached RAM, returning to memory-mapped access.

class

LevelsComputed

(Computed)

C.levels: node type hierarchy data.

class

OrderComputed

(Computed)

C.order: nodes in canonical order.

C.order: nodes in canonical order. Supports numpy array backend for mmap. data[i] gives node at position i.
class

RankComputed

(Computed)

C.rank: canonical position of each node.

C.rank: canonical position of each node. Supports numpy array backend for mmap. data[n-1] gives rank of node n.