Skip to content

Base chunk reader

Contract shared by all subgraph-read strategies.

BaseChunkReader

Bases: ABC

Reads a chunk's retrievable payload back from one graph backend.

Implementations encapsulate the backend-specific queries that read the Element-shaped payload (text/structure/metadata) a writer previously stamped onto a chunk's Chunk node, restoring the GraphIndexer.get_chunk / get_file_chunks contract on top of a graph backend.

get_chunk(chunk_id, index_name) abstractmethod

Get a single chunk's retrievable payload by chunk id.

Parameters:

Name Type Description Default
chunk_id str

Raw (un-namespaced) chunk identifier.

required
index_name str

Namespace scoping the lookup.

required

Returns:

Type Description
dict[str, Any] | None

dict[str, Any] | None: The chunk's Element-shaped payload (text, structure, metadata), or None if not found.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.

get_file_chunks(file_id, index_name, page, size) abstractmethod

Get a page of a file's chunks, ordered by their position within the file.

Parameters:

Name Type Description Default
file_id str

The file identifier chunks were indexed under.

required
index_name str

Namespace scoping the lookup.

required
page int

The page number (0-indexed).

required
size int

The number of chunks per page.

required

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Response with chunks (list of Element-shaped payloads) and pagination metadata.

Raises:

Type Description
NotImplementedError

Always raised by the base implementation.