Class AlloyDBLoader.Builder
java.lang.Object
dev.langchain4j.community.data.document.loader.alloydb.AlloyDBLoader.Builder
- Enclosing class:
AlloyDBLoader
Builder for
AlloyDBLoader.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds anAlloyDBLoaderwith the configuration applied to this builder.contentColumns(List<String> contentColumns) Sets the list of columns to use for the document content.Sets the format for the document content.Sets a custom formatter to convert row data into document content.metadataColumns(List<String> metadataColumns) Sets the list of columns to use for the document metadata.metadataJsonColumn(String metadataJsonColumn) Sets the column name containing JSON metadata.Sets the SQL query to execute.schemaName(String schemaName) Sets the schema name for the table.Sets the table name to load data from.
-
Constructor Details
-
Builder
Construct a LoaderBuilder.- Parameters:
engine- The AlloyDBEngine.
-
-
Method Details
-
schemaName
Sets the schema name for the table. Defaults to "public".- Parameters:
schemaName- The schema name.- Returns:
- This Builder.
-
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
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
public AlloyDBLoader.Builder formatter(BiFunction<Map<String, Object>, List<String>, String> formatter) Sets a custom formatter to convert row data into document content.- Parameters:
formatter- The formatter function.- Returns:
- This Builder.
-
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
Sets the list of columns to use for the document content.- Parameters:
contentColumns- The content column names.- Returns:
- This Builder.
-
metadataColumns
Sets the list of columns to use for the document metadata.- Parameters:
metadataColumns- The metadata column names.- Returns:
- This Builder.
-
metadataJsonColumn
Sets the column name containing JSON metadata.- Parameters:
metadataJsonColumn- The JSON metadata column name.- Returns:
- This Builder.
-
build
Builds anAlloyDBLoaderwith the configuration applied to this builder.- Returns:
- The built
AlloyDBLoaderinstance. - 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.
-