Home / Class/ RecordManager Class — langchain Architecture

RecordManager Class — langchain Architecture

Architecture documentation for the RecordManager class in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d5396e7d_8f96_f74d_2e53_741efbe757bc["RecordManager"]
  44ffc3da_66a5_f9ca_57ac_f9a80e82f0c8["base.py"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|defined in| 44ffc3da_66a5_f9ca_57ac_f9a80e82f0c8
  a4730615_0eb4_08d6_9838_47e9f63b0fc4["__init__()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| a4730615_0eb4_08d6_9838_47e9f63b0fc4
  95778eee_eda5_90f1_98c7_63326d8e139c["create_schema()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 95778eee_eda5_90f1_98c7_63326d8e139c
  b7b6e417_e80e_56a8_354f_879c2a4b1eee["acreate_schema()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| b7b6e417_e80e_56a8_354f_879c2a4b1eee
  cc21c1ca_7036_9f46_1ebc_5bd8dddcff22["get_time()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| cc21c1ca_7036_9f46_1ebc_5bd8dddcff22
  7c2b38d3_34fd_6746_ae1c_a20ccf550677["aget_time()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 7c2b38d3_34fd_6746_ae1c_a20ccf550677
  28e3368a_7123_c390_bc52_cb21a29944da["update()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 28e3368a_7123_c390_bc52_cb21a29944da
  c7f1d849_b5bc_c925_0c0a_a8a5133218d1["aupdate()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| c7f1d849_b5bc_c925_0c0a_a8a5133218d1
  12d18893_0ae3_e621_0bc3_bb411ef4b78e["exists()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 12d18893_0ae3_e621_0bc3_bb411ef4b78e
  88ccbad9_faee_3f02_23af_eee25f7638e0["aexists()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 88ccbad9_faee_3f02_23af_eee25f7638e0
  264befbe_5025_a782_2d5b_6d78d8b41f7e["list_keys()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 264befbe_5025_a782_2d5b_6d78d8b41f7e
  b72d1140_a0ae_88e6_d5c8_2233b054a180["alist_keys()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| b72d1140_a0ae_88e6_d5c8_2233b054a180
  4a537306_4f8b_d748_d404_8428e385a450["delete_keys()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| 4a537306_4f8b_d748_d404_8428e385a450
  b16ae3f4_a913_b5cd_0b90_73626dfdc4d6["adelete_keys()"]
  d5396e7d_8f96_f74d_2e53_741efbe757bc -->|method| b16ae3f4_a913_b5cd_0b90_73626dfdc4d6

Relationship Graph

Source Code

libs/core/langchain_core/indexing/base.py lines 22–232

class RecordManager(ABC):
    """Abstract base class representing the interface for a record manager.

    The record manager abstraction is used by the langchain indexing API.

    The record manager keeps track of which documents have been
    written into a `VectorStore` and when they were written.

    The indexing API computes hashes for each document and stores the hash
    together with the write time and the source id in the record manager.

    On subsequent indexing runs, the indexing API can check the record manager
    to determine which documents have already been indexed and which have not.

    This allows the indexing API to avoid re-indexing documents that have
    already been indexed, and to only index new documents.

    The main benefit of this abstraction is that it works across many vectorstores.
    To be supported, a `VectorStore` needs to only support the ability to add and
    delete documents by ID. Using the record manager, the indexing API will
    be able to delete outdated documents and avoid redundant indexing of documents
    that have already been indexed.

    The main constraints of this abstraction are:

    1. It relies on the time-stamps to determine which documents have been
        indexed and which have not. This means that the time-stamps must be
        monotonically increasing. The timestamp should be the timestamp
        as measured by the server to minimize issues.
    2. The record manager is currently implemented separately from the
        vectorstore, which means that the overall system becomes distributed
        and may create issues with consistency. For example, writing to
        record manager succeeds, but corresponding writing to `VectorStore` fails.
    """

    def __init__(
        self,
        namespace: str,
    ) -> None:
        """Initialize the record manager.

        Args:
            namespace: The namespace for the record manager.
        """
        self.namespace = namespace

    @abstractmethod
    def create_schema(self) -> None:
        """Create the database schema for the record manager."""

    @abstractmethod
    async def acreate_schema(self) -> None:
        """Asynchronously create the database schema for the record manager."""

    @abstractmethod
    def get_time(self) -> float:
        """Get the current server time as a high resolution timestamp!

        It's important to get this from the server to ensure a monotonic clock,
        otherwise there may be data loss when cleaning up old documents!

        Returns:
            The current server time as a float timestamp.
        """

    @abstractmethod
    async def aget_time(self) -> float:
        """Asynchronously get the current server time as a high resolution timestamp.

        It's important to get this from the server to ensure a monotonic clock,
        otherwise there may be data loss when cleaning up old documents!

        Returns:
            The current server time as a float timestamp.
        """

    @abstractmethod
    def update(
        self,
        keys: Sequence[str],
        *,

Frequently Asked Questions

What is the RecordManager class?
RecordManager is a class in the langchain codebase, defined in libs/core/langchain_core/indexing/base.py.
Where is RecordManager defined?
RecordManager is defined in libs/core/langchain_core/indexing/base.py at line 22.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free