From 7229af8535daa450ebafd6c45c322222a2dd12a0 Mon Sep 17 00:00:00 2001 From: "bosun-ai[bot]" <157630444+bosun-ai[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:48:18 +0200 Subject: [PATCH] docs(swiftide): documented file swiftide/src/integrations/qdrant/persist.rs (#24) Co-authored-by: bosun-ai[bot] <157630444+bosun-ai[bot]@users.noreply.github.com> --- swiftide/src/integrations/qdrant/persist.rs | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/swiftide/src/integrations/qdrant/persist.rs b/swiftide/src/integrations/qdrant/persist.rs index b3857ea1..81cac74a 100644 --- a/swiftide/src/integrations/qdrant/persist.rs +++ b/swiftide/src/integrations/qdrant/persist.rs @@ -1,3 +1,7 @@ +//! This module provides an implementation of the `Storage` trait for the `Qdrant` struct. +//! It includes methods for setting up the storage, storing a single node, and storing a batch of nodes. +//! This integration allows the Swiftide project to use Qdrant as a storage backend. + use anyhow::Result; use async_trait::async_trait; @@ -7,16 +11,43 @@ use super::Qdrant; #[async_trait] impl Storage for Qdrant { + /// Returns the batch size for the Qdrant storage. + /// + /// # Returns + /// + /// An `Option` representing the batch size if set, otherwise `None`. fn batch_size(&self) -> Option { self.batch_size } + /// Sets up the Qdrant storage by creating the necessary index if it does not exist. + /// + /// # Returns + /// + /// A `Result<()>` which is `Ok` if the setup is successful, otherwise an error. + /// + /// # Errors + /// + /// This function will return an error if the index creation fails. #[tracing::instrument(skip_all, err)] async fn setup(&self) -> Result<()> { tracing::debug!("Setting up Qdrant storage"); self.create_index_if_not_exists().await } + /// Stores a single ingestion node in the Qdrant storage. + /// + /// # Parameters + /// + /// - `node`: The `IngestionNode` to be stored. + /// + /// # Returns + /// + /// A `Result<()>` which is `Ok` if the storage is successful, otherwise an error. + /// + /// # Errors + /// + /// This function will return an error if the node conversion or storage operation fails. #[tracing::instrument(skip_all, err, name = "storage.qdrant.store")] async fn store(&self, node: crate::ingestion::IngestionNode) -> Result<()> { self.client @@ -30,6 +61,19 @@ impl Storage for Qdrant { Ok(()) } + /// Stores a batch of ingestion nodes in the Qdrant storage. + /// + /// # Parameters + /// + /// - `nodes`: A vector of `IngestionNode` to be stored. + /// + /// # Returns + /// + /// A `Result<()>` which is `Ok` if the storage is successful, otherwise an error. + /// + /// # Errors + /// + /// This function will return an error if any node conversion or storage operation fails. #[tracing::instrument(skip_all, err, name = "storage.qdrant.batch_store")] async fn batch_store(&self, nodes: Vec) -> Result<()> { self.client