java.lang.Object
dev.langchain4j.community.data.document.loader.alloydb.AlloyDBLoader

public class AlloyDBLoader extends Object
AlloyDBLoader

This loader allows you to retrieve data from AlloyDB using either a custom SQL query or a table name. You can specify which columns should be used for the document's content and which for its metadata. Additionally, you can format the content using predefined formats (CSV, text, JSON, YAML) or a custom formatter. Metadata can be loaded from specified columns or from a JSON column.

  • Method Details

    • load

      public List<dev.langchain4j.data.document.Document> load() throws SQLException
      Executes the configured SQL query against the AlloyDB database and transforms the result set into a list of Document objects.

      Each row in the result set is processed according to the configured content columns, metadata columns, and formatter. The content is extracted and formatted, and metadata is assembled from the specified columns or the JSON metadata column.

      Returns:
      A list of Document objects, where each document represents a row from the database result set.
      Throws:
      SQLException - If a database error occurs during the execution of the query or while processing the result set. This could include issues such as connection problems, SQL syntax errors, or data retrieval failures.
      RuntimeException - If there's an error parsing the JSON metadata column, indicating an issue with the JSON structure.
    • builder

      public static AlloyDBLoader.Builder builder(AlloyDBEngine engine)
      Create a new AlloyDBLoader.Builder.
      Parameters:
      engine - The AlloyDB Engine
      Returns:
      the new AlloyDBLoader.Builder.