Class JdbcRowDataInputFormat

  • All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<org.apache.flink.table.data.RowData>, org.apache.flink.core.io.InputSplitSource<org.apache.flink.core.io.InputSplit>

    @Internal
    public class JdbcRowDataInputFormat
    extends org.apache.flink.api.common.io.RichInputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
    implements org.apache.flink.api.java.typeutils.ResultTypeQueryable<org.apache.flink.table.data.RowData>
    InputFormat for JdbcDynamicTableSource.
    See Also:
    Serialized Form
    • Method Detail

      • configure

        public void configure​(org.apache.flink.configuration.Configuration parameters)
        Specified by:
        configure in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
      • openInputFormat

        public void openInputFormat()
        Overrides:
        openInputFormat in class org.apache.flink.api.common.io.RichInputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
      • closeInputFormat

        public void closeInputFormat()
        Overrides:
        closeInputFormat in class org.apache.flink.api.common.io.RichInputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
      • open

        public void open​(org.apache.flink.core.io.InputSplit inputSplit)
                  throws IOException
        Connects to the source database and executes the query in a parallel fashion if this InputFormat is built using a parameterized query (i.e. using a PreparedStatement) and a proper JdbcParameterValuesProvider, in a non-parallel fashion otherwise.
        Specified by:
        open in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Parameters:
        inputSplit - which is ignored if this InputFormat is executed as a non-parallel source, a "hook" to the query parameters otherwise (using its splitNumber)
        Throws:
        IOException - if there's an error during the execution of the query
      • close

        public void close()
                   throws IOException
        Closes all resources used.
        Specified by:
        close in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Throws:
        IOException - Indicates that a resource could not be closed.
      • getProducedType

        public org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.table.data.RowData> getProducedType()
        Specified by:
        getProducedType in interface org.apache.flink.api.java.typeutils.ResultTypeQueryable<org.apache.flink.table.data.RowData>
      • reachedEnd

        public boolean reachedEnd()
                           throws IOException
        Checks whether all data has been read.
        Specified by:
        reachedEnd in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Returns:
        boolean value indication whether all data has been read.
        Throws:
        IOException
      • nextRecord

        public org.apache.flink.table.data.RowData nextRecord​(org.apache.flink.table.data.RowData reuse)
                                                       throws IOException
        Stores the next resultSet row in a tuple.
        Specified by:
        nextRecord in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Parameters:
        reuse - row to be reused.
        Returns:
        row containing next RowData
        Throws:
        IOException
      • getStatistics

        public org.apache.flink.api.common.io.statistics.BaseStatistics getStatistics​(org.apache.flink.api.common.io.statistics.BaseStatistics cachedStatistics)
                                                                               throws IOException
        Specified by:
        getStatistics in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Throws:
        IOException
      • createInputSplits

        public org.apache.flink.core.io.InputSplit[] createInputSplits​(int minNumSplits)
                                                                throws IOException
        Specified by:
        createInputSplits in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Specified by:
        createInputSplits in interface org.apache.flink.core.io.InputSplitSource<org.apache.flink.core.io.InputSplit>
        Throws:
        IOException
      • getInputSplitAssigner

        public org.apache.flink.core.io.InputSplitAssigner getInputSplitAssigner​(org.apache.flink.core.io.InputSplit[] inputSplits)
        Specified by:
        getInputSplitAssigner in interface org.apache.flink.api.common.io.InputFormat<org.apache.flink.table.data.RowData,​org.apache.flink.core.io.InputSplit>
        Specified by:
        getInputSplitAssigner in interface org.apache.flink.core.io.InputSplitSource<org.apache.flink.core.io.InputSplit>
      • builder

        public static JdbcRowDataInputFormat.Builder builder()
        A builder used to set parameters to the output format's configuration in a fluent way.
        Returns:
        builder