Skip to content

Base chunk subgraph writer

Contract shared by all subgraph-write strategies.

BaseChunkSubgraphWriter

Bases: ABC

Upserts a batch of regulation nodes and edges into one backend.

Implementations encapsulate the backend-specific writes that persist the pre-generated, already-deduplicated nodes and edges of a document's chunks. A single upsert_subgraph call owns the two-pass ordering — every node is written before any edge — so cross-chunk relationship endpoints exist by the time relationships are written; an edge whose endpoints are absent is silently skipped.

upsert_subgraph(nodes, edges) abstractmethod

Upsert nodes and then edges into the backend.

All nodes are upserted before any edge so cross-chunk relationship endpoints exist when relationships are written; an edge whose endpoints do not exist is silently skipped. Each node's and edge's metadata already carries the indexer's index_name namespace property.

Parameters:

Name Type Description Default
nodes list[Node]

Nodes to upsert; id is the identity key.

required
edges list[Edge]

Edges to upsert; both endpoints are matched by id.

required

Returns:

Type Description
tuple[int, int]

tuple[int, int]: (nodes_written, edges_written) — the counts submitted.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.