Class BaseChangeRecordEmitter<T>

All Implemented Interfaces:
ChangeRecordEmitter
Direct Known Subclasses:
LogMinerChangeRecordEmitter, XStreamChangeRecordEmitter

public abstract class BaseChangeRecordEmitter<T> extends RelationalChangeRecordEmitter
Base class to emit change data based on a single entry event.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • connectorConfig

      private final OracleConnectorConfig connectorConfig
    • oldColumnValues

      private final Object[] oldColumnValues
    • newColumnValues

      private final Object[] newColumnValues
    • schema

      private final OracleDatabaseSchema schema
    • table

      protected final Table table
  • Constructor Details

  • Method Details

    • getOldColumnValues

      protected Object[] getOldColumnValues()
      Specified by:
      getOldColumnValues in class RelationalChangeRecordEmitter
    • getNewColumnValues

      protected Object[] getNewColumnValues()
      Specified by:
      getNewColumnValues in class RelationalChangeRecordEmitter
    • emitTruncateRecord

      protected void emitTruncateRecord(ChangeRecordEmitter.Receiver receiver, TableSchema tableSchema) throws InterruptedException
      Overrides:
      emitTruncateRecord in class RelationalChangeRecordEmitter
      Throws:
      InterruptedException
    • emitUpdateAsPrimaryKeyChangeRecord

      protected void emitUpdateAsPrimaryKeyChangeRecord(ChangeRecordEmitter.Receiver receiver, TableSchema tableSchema, org.apache.kafka.connect.data.Struct oldKey, org.apache.kafka.connect.data.Struct newKey, org.apache.kafka.connect.data.Struct oldValue, org.apache.kafka.connect.data.Struct newValue) throws InterruptedException
      Overrides:
      emitUpdateAsPrimaryKeyChangeRecord in class RelationalChangeRecordEmitter
      Throws:
      InterruptedException
    • getReselectColumns

      private List<Column> getReselectColumns(org.apache.kafka.connect.data.Struct newValue)
      Returns a list of columns that should be reselected. Currently, this method is only concerned about LOB-based columns and so if a table does not have any LOB columns or if the LOB column's value is not the unavailable value placeholder configured in the connector configuration, this method may return no columns indicating that a reselection is not required for the change event.
      Parameters:
      newValue - the currently constructed new value payload for the change event, should not be null
      Returns:
      list of columns that should be reselected, which can be empty
    • getReselectQuery

      private String getReselectQuery(List<Column> reselectColumns, Table table, OracleConnection connection)
      Creates the reselect query, a query that explicitly only selects the LOB-based columns from the underlying relational table based on the event's current primary key value set.
      Parameters:
      reselectColumns - the columns that should be reselected, should never be null or empty
      table - the relational table model
      connection - the database connection
      Returns:
      the query string for the reselect query
    • prepareReselectQueryStatement

      private void prepareReselectQueryStatement(PreparedStatement ps, Table table, org.apache.kafka.connect.data.Struct newKey) throws SQLException
      Prepares the reselect query, binding the primary key column values
      Parameters:
      ps - the prepared statement
      table - the relational model table
      newKey - the row's new key
      Throws:
      SQLException - if a database error occurred
    • updateNewValuesFromReselectQueryResults

      private void updateNewValuesFromReselectQueryResults(ResultSet rs, List<Column> reselectColumns) throws SQLException
      Applies the reselect query results to the new column values object array.
      Parameters:
      rs - the reselect query result set
      reselectColumns - the columns that were re-selected
      Throws:
      SQLException - if a database error occurred