InMemoryVectorStorageBackend

A concrete implementation of VectorStorageBackend that stores documents and their associated vector embeddings in memory.

Use this class to manage the storage and retrieval of documents and their vector-based data without relying on any external persistent storage. This is suitable for in-memory operations and testing environments where persistent storage is not required.

Type Parameters

Document

The type of document managed by this storage.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open override fun allDocuments(): Flow<Document>

Retrieves a flow of all documents.

Link copied to clipboard

Retrieves a flow of all documents with their vector embeddings.

Link copied to clipboard
open suspend override fun delete(documentId: String): Boolean

Deletes the document with the specified ID.

Link copied to clipboard
open suspend override fun read(documentId: String): Document?

Reads a document by its unique identifier.

Link copied to clipboard
open suspend override fun readWithPayload(documentId: String): DocumentWithPayload<Document, Vector>?

Reads a document along with its vector embedding by document ID.

Link copied to clipboard
open suspend override fun store(document: Document, vector: Vector): String

Stores a document along with its pre-computed vector embedding.

open suspend override fun store(id: String, document: Document, vector: Vector): Boolean

Updates a document along with its pre-computed vector embedding under the specified ID. Only updates if a document with the given ID already exists.