Class AlloyDBLoader.Builder

java.lang.Object
dev.langchain4j.community.data.document.loader.alloydb.AlloyDBLoader.Builder
Enclosing class:
AlloyDBLoader

public static class AlloyDBLoader.Builder extends Object
Builder for AlloyDBLoader.
  • Constructor Details

    • Builder

      public Builder(AlloyDBEngine engine)
      Construct a LoaderBuilder.
      Parameters:
      engine - The AlloyDBEngine.
  • Method Details

    • schemaName

      public AlloyDBLoader.Builder schemaName(String schemaName)
      Sets the schema name for the table. Defaults to "public".
      Parameters:
      schemaName - The schema name.
      Returns:
      This Builder.
    • query

      public AlloyDBLoader.Builder query(String query)
      Sets the SQL query to execute. If not provided, a default query is generated from the table name.
      Parameters:
      query - The SQL query.
      Returns:
      This Builder.
    • tableName

      public AlloyDBLoader.Builder tableName(String tableName)
      Sets the table name to load data from. If not provided, a custom query must be specified.
      Parameters:
      tableName - The table name.
      Returns:
      This Builder.
    • formatter

      Sets a custom formatter to convert row data into document content.
      Parameters:
      formatter - The formatter function.
      Returns:
      This Builder.
    • format

      public AlloyDBLoader.Builder format(String format)
      Sets the format for the document content. Predefined formats are "csv", "text", "JSON", and "YAML". Only one of format or formatter should be specified.
      Parameters:
      format - The format string.
      Returns:
      This Builder.
    • contentColumns

      public AlloyDBLoader.Builder contentColumns(List<String> contentColumns)
      Sets the list of columns to use for the document content.
      Parameters:
      contentColumns - The content column names.
      Returns:
      This Builder.
    • metadataColumns

      public AlloyDBLoader.Builder metadataColumns(List<String> metadataColumns)
      Sets the list of columns to use for the document metadata.
      Parameters:
      metadataColumns - The metadata column names.
      Returns:
      This Builder.
    • metadataJsonColumn

      public AlloyDBLoader.Builder metadataJsonColumn(String metadataJsonColumn)
      Sets the column name containing JSON metadata.
      Parameters:
      metadataJsonColumn - The JSON metadata column name.
      Returns:
      This Builder.
    • build

      public AlloyDBLoader build() throws SQLException
      Builds an AlloyDBLoader with the configuration applied to this builder.
      Returns:
      The built AlloyDBLoader instance.
      Throws:
      IllegalArgumentException - if neither query nor tableName is specified, or if both format and formatter are specified, or if specified column not found.
      SQLException - if a database error occurs.