public class JdbcToArrowConfigBuilder extends Object
JdbcToArrowConfig
s.Constructor and Description |
---|
JdbcToArrowConfigBuilder()
Default constructor for the
JdbcToArrowConfigBuilder} . |
JdbcToArrowConfigBuilder(BufferAllocator allocator,
Calendar calendar)
Constructor for the
JdbcToArrowConfigBuilder . |
JdbcToArrowConfigBuilder(BufferAllocator allocator,
Calendar calendar,
boolean includeMetadata)
Constructor for the
JdbcToArrowConfigBuilder . |
Modifier and Type | Method and Description |
---|---|
JdbcToArrowConfig |
build()
|
JdbcToArrowConfigBuilder |
setAllocator(BufferAllocator allocator)
Sets the memory allocator to use when constructing the Arrow vectors from the ResultSet.
|
JdbcToArrowConfigBuilder |
setArraySubTypeByColumnIndexMap(Map<Integer,JdbcFieldInfo> map)
Sets the mapping of column-index-to-
JdbcFieldInfo used for columns of type Types.ARRAY . |
JdbcToArrowConfigBuilder |
setArraySubTypeByColumnNameMap(Map<String,JdbcFieldInfo> map)
Sets the mapping of column-name-to-
JdbcFieldInfo used for columns of type Types.ARRAY . |
JdbcToArrowConfigBuilder |
setBigDecimalRoundingMode(RoundingMode bigDecimalRoundingMode)
Set the rounding mode used when the scale of the actual value does not match the declared scale.
|
JdbcToArrowConfigBuilder |
setCalendar(Calendar calendar)
Sets the
Calendar to use when constructing timestamp fields in the
Arrow schema, and reading time-based fields from the JDBC ResultSet . |
JdbcToArrowConfigBuilder |
setColumnMetadataByColumnIndex(Map<Integer,Map<String,String>> columnMetadataByColumnIndex)
Set metadata from columnIndex->meta map on per field basis.
|
JdbcToArrowConfigBuilder |
setExplicitTypesByColumnIndex(Map<Integer,JdbcFieldInfo> map)
Sets the mapping of column-index-to-
JdbcFieldInfo used for column types. |
JdbcToArrowConfigBuilder |
setExplicitTypesByColumnName(Map<String,JdbcFieldInfo> map)
Sets the mapping of column-name-to-
JdbcFieldInfo used for column types. |
JdbcToArrowConfigBuilder |
setIncludeMetadata(boolean includeMetadata)
Sets whether to include JDBC ResultSet field metadata in the Arrow Schema field metadata.
|
JdbcToArrowConfigBuilder |
setJdbcToArrowTypeConverter(Function<JdbcFieldInfo,ArrowType> jdbcToArrowTypeConverter)
Set the function used to convert JDBC types to Arrow types.
|
JdbcToArrowConfigBuilder |
setReuseVectorSchemaRoot(boolean reuseVectorSchemaRoot)
Set whether to use the same
VectorSchemaRoot instance on each iteration,
or to allocate a new one. |
JdbcToArrowConfigBuilder |
setSchemaMetadata(Map<String,String> schemaMetadata)
Set metadata for schema.
|
JdbcToArrowConfigBuilder |
setTargetBatchSize(int targetBatchSize)
Set the target number of rows to convert at once.
|
public JdbcToArrowConfigBuilder()
JdbcToArrowConfigBuilder}
.
Use the setter methods for the allocator and calendar; the allocator must be
set. Otherwise, build()
will throw a NullPointerException
.public JdbcToArrowConfigBuilder(BufferAllocator allocator, Calendar calendar)
JdbcToArrowConfigBuilder
. The
allocator is required, and a NullPointerException
will be thrown if it is null
.
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 convert Date
, Time
, and
Timestamp
fields to a single, common time zone when reading
from the result set.
allocator
- The Arrow Vector memory allocator.calendar
- The calendar to use when constructing timestamp fields.public JdbcToArrowConfigBuilder(BufferAllocator allocator, Calendar calendar, boolean includeMetadata)
JdbcToArrowConfigBuilder
. Both the
allocator and calendar are required. A NullPointerException
will be thrown if either of those arguments is null
.
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 convert Date
, Time
, and
Timestamp
fields to a single, common time zone when reading
from the result set.
The includeMetadata
argument, if true
will cause
various information about each database field to be added to the Vector
Schema's field metadata.
allocator
- The Arrow Vector memory allocator.calendar
- The calendar to use when constructing timestamp fields.public JdbcToArrowConfigBuilder setAllocator(BufferAllocator allocator)
allocator
- the allocator to set.NullPointerException
- if allocator
is null.public JdbcToArrowConfigBuilder setCalendar(Calendar calendar)
Calendar
to use when constructing timestamp fields in the
Arrow schema, and reading time-based fields from the JDBC ResultSet
.calendar
- the calendar to set.public JdbcToArrowConfigBuilder setIncludeMetadata(boolean includeMetadata)
includeMetadata
- Whether to include or exclude JDBC metadata in the Arrow Schema field metadata.JdbcToArrowConfig
, for chaining.public JdbcToArrowConfigBuilder setArraySubTypeByColumnIndexMap(Map<Integer,JdbcFieldInfo> map)
JdbcFieldInfo
used for columns of type Types.ARRAY
.
The column index is 1-based, to match the JDBC column index.map
- The mapping.JdbcToArrowConfig
, for chaining.public JdbcToArrowConfigBuilder setArraySubTypeByColumnNameMap(Map<String,JdbcFieldInfo> map)
JdbcFieldInfo
used for columns of type Types.ARRAY
.map
- The mapping.JdbcToArrowConfig
, for chaining.public JdbcToArrowConfigBuilder setExplicitTypesByColumnIndex(Map<Integer,JdbcFieldInfo> map)
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.
map
- The mapping.public JdbcToArrowConfigBuilder setExplicitTypesByColumnName(Map<String,JdbcFieldInfo> map)
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.
map
- The mapping.public JdbcToArrowConfigBuilder setTargetBatchSize(int targetBatchSize)
Use JdbcToArrowConfig.NO_LIMIT_BATCH_SIZE
to read all rows at once.
public JdbcToArrowConfigBuilder setJdbcToArrowTypeConverter(Function<JdbcFieldInfo,ArrowType> jdbcToArrowTypeConverter)
Defaults to wrapping JdbcToArrowUtils.getArrowTypeFromJdbcType(JdbcFieldInfo, Calendar)
.
public JdbcToArrowConfigBuilder setReuseVectorSchemaRoot(boolean reuseVectorSchemaRoot)
VectorSchemaRoot
instance on each iteration,
or to allocate a new one.public JdbcToArrowConfigBuilder setSchemaMetadata(Map<String,String> schemaMetadata)
public JdbcToArrowConfigBuilder setColumnMetadataByColumnIndex(Map<Integer,Map<String,String>> columnMetadataByColumnIndex)
public JdbcToArrowConfigBuilder setBigDecimalRoundingMode(RoundingMode bigDecimalRoundingMode)
By default, an error is raised in such cases.
public JdbcToArrowConfig build()
JdbcToArrowConfig
NullPointerException
- if either the allocator or calendar was not set.Copyright © 2023 The Apache Software Foundation. All rights reserved.