Class JdbcToArrowConfigBuilder
JdbcToArrowConfig
s.-
Constructor Summary
ConstructorDescriptionDefault constructor for theJdbcToArrowConfigBuilder}
.JdbcToArrowConfigBuilder
(BufferAllocator allocator, Calendar calendar) Constructor for theJdbcToArrowConfigBuilder
.JdbcToArrowConfigBuilder
(BufferAllocator allocator, Calendar calendar, boolean includeMetadata) Constructor for theJdbcToArrowConfigBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
setAllocator
(BufferAllocator allocator) Sets the memory allocator to use when constructing the Arrow vectors from the ResultSet.Sets the mapping of column-index-to-JdbcFieldInfo
used for columns of typeTypes.ARRAY
.Sets the mapping of column-name-to-JdbcFieldInfo
used for columns of typeTypes.ARRAY
.setBigDecimalRoundingMode
(RoundingMode bigDecimalRoundingMode) Set the rounding mode used when the scale of the actual value does not match the declared scale.setCalendar
(Calendar calendar) Sets theCalendar
to use when constructing timestamp fields in the Arrow schema, and reading time-based fields from the JDBCResultSet
.Set metadata from columnIndex->meta map on per field basis.Sets the mapping of column-index-to-JdbcFieldInfo
used for column types.Sets the mapping of column-name-to-JdbcFieldInfo
used for column types.setIncludeMetadata
(boolean includeMetadata) Sets whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata.setJdbcConsumerGetter
(JdbcToArrowConfig.JdbcConsumerFactory jdbcConsumerGetter) Set the function used to get a JDBC consumer for a given type.setJdbcToArrowTypeConverter
(Function<JdbcFieldInfo, ArrowType> jdbcToArrowTypeConverter) Set the function used to convert JDBC types to Arrow types.setReuseVectorSchemaRoot
(boolean reuseVectorSchemaRoot) Set whether to use the sameVectorSchemaRoot
instance on each iteration, or to allocate a new one.setSchemaMetadata
(Map<String, String> schemaMetadata) Set metadata for schema.setTargetBatchSize
(int targetBatchSize) Set the target number of rows to convert at once.
-
Constructor Details
-
JdbcToArrowConfigBuilder
public JdbcToArrowConfigBuilder()Default constructor for theJdbcToArrowConfigBuilder}
. Use the setter methods for the allocator and calendar; the allocator must be set. Otherwise,build()
will throw aNullPointerException
. -
JdbcToArrowConfigBuilder
Constructor for theJdbcToArrowConfigBuilder
. The allocator is required, and aNullPointerException
will be thrown if it isnull
.The allocator is used to construct Arrow vectors from the JDBC ResultSet. The calendar is used to determine the time zone of
Timestamp
fields and convertDate
,Time
, andTimestamp
fields to a single, common time zone when reading from the result set.- Parameters:
allocator
- The Arrow Vector memory allocator.calendar
- The calendar to use when constructing timestamp fields.
-
JdbcToArrowConfigBuilder
public JdbcToArrowConfigBuilder(BufferAllocator allocator, Calendar calendar, boolean includeMetadata) Constructor for theJdbcToArrowConfigBuilder
. Both the allocator and calendar are required. ANullPointerException
will be thrown if either of those arguments isnull
.The allocator is used to construct Arrow vectors from the JDBC ResultSet. The calendar is used to determine the time zone of
Timestamp
fields and convertDate
,Time
, andTimestamp
fields to a single, common time zone when reading from the result set.The
includeMetadata
argument, iftrue
will cause various information about each database field to be added to the Vector Schema's field metadata.- Parameters:
allocator
- The Arrow Vector memory allocator.calendar
- The calendar to use when constructing timestamp fields.
-
-
Method Details
-
setAllocator
Sets the memory allocator to use when constructing the Arrow vectors from the ResultSet.- Parameters:
allocator
- the allocator to set.- Throws:
NullPointerException
- ifallocator
is null.
-
setCalendar
Sets theCalendar
to use when constructing timestamp fields in the Arrow schema, and reading time-based fields from the JDBCResultSet
.- Parameters:
calendar
- the calendar to set.
-
setIncludeMetadata
Sets whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata.- Parameters:
includeMetadata
- Whether to include or exclude JDBC metadata in the Arrow Schema field metadata.- Returns:
- This instance of the
JdbcToArrowConfig
, for chaining.
-
setArraySubTypeByColumnIndexMap
Sets the mapping of column-index-to-JdbcFieldInfo
used for columns of typeTypes.ARRAY
. The column index is 1-based, to match the JDBC column index.- Parameters:
map
- The mapping.- Returns:
- This instance of the
JdbcToArrowConfig
, for chaining.
-
setArraySubTypeByColumnNameMap
Sets the mapping of column-name-to-JdbcFieldInfo
used for columns of typeTypes.ARRAY
.- Parameters:
map
- The mapping.- Returns:
- This instance of the
JdbcToArrowConfig
, for chaining.
-
setExplicitTypesByColumnIndex
Sets the mapping of column-index-to-JdbcFieldInfo
used for column types.This can be useful to override type information from JDBC drivers that provide incomplete type info, e.g. DECIMAL with precision = scale = 0.
The column index is 1-based, to match the JDBC column index.
- Parameters:
map
- The mapping.
-
setExplicitTypesByColumnName
Sets the mapping of column-name-to-JdbcFieldInfo
used for column types.This can be useful to override type information from JDBC drivers that provide incomplete type info, e.g. DECIMAL with precision = scale = 0.
- Parameters:
map
- The mapping.
-
setTargetBatchSize
Set the target number of rows to convert at once.Use
JdbcToArrowConfig.NO_LIMIT_BATCH_SIZE
to read all rows at once. -
setJdbcToArrowTypeConverter
public JdbcToArrowConfigBuilder setJdbcToArrowTypeConverter(Function<JdbcFieldInfo, ArrowType> jdbcToArrowTypeConverter) Set the function used to convert JDBC types to Arrow types.Defaults to wrapping
JdbcToArrowUtils.getArrowTypeFromJdbcType(JdbcFieldInfo, Calendar)
. -
setJdbcConsumerGetter
public JdbcToArrowConfigBuilder setJdbcConsumerGetter(JdbcToArrowConfig.JdbcConsumerFactory jdbcConsumerGetter) Set the function used to get a JDBC consumer for a given type.Defaults to wrapping
JdbcToArrowUtils#getConsumer(ArrowType, Integer, Boolean, FieldVector, JdbcToArrowConfig)
. -
setReuseVectorSchemaRoot
Set whether to use the sameVectorSchemaRoot
instance on each iteration, or to allocate a new one. -
setSchemaMetadata
Set metadata for schema. -
setColumnMetadataByColumnIndex
public JdbcToArrowConfigBuilder setColumnMetadataByColumnIndex(Map<Integer, Map<String, String>> columnMetadataByColumnIndex) Set metadata from columnIndex->meta map on per field basis. -
setBigDecimalRoundingMode
Set the rounding mode used when the scale of the actual value does not match the declared scale.By default, an error is raised in such cases.
-
build
- Returns:
- The built
JdbcToArrowConfig
- Throws:
NullPointerException
- if either the allocator or calendar was not set.
-