Skip to content

Commit

Permalink
Refactor DumperCommonContext
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 4, 2023
1 parent 25215d3 commit c67ffd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,4 @@ public abstract class DumperCommonContext {
private TableAndSchemaNameMapper tableAndSchemaNameMapper;

private IngestPosition position;

/**
* Get schema name.
*
* @param actualTableName actual table name
* @return schema name, can be nullable
*/
public String getSchemaName(final String actualTableName) {
return tableAndSchemaNameMapper.getSchemaName(tableNameMapper.getLogicTableName(actualTableName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.PlaceholderRecord;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.Record;
import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
import org.apache.shardingsphere.data.pipeline.api.metadata.loader.PipelineTableMetaDataLoader;
import org.apache.shardingsphere.data.pipeline.api.metadata.model.PipelineColumnMetaData;
import org.apache.shardingsphere.data.pipeline.api.metadata.model.PipelineTableMetaData;
Expand Down Expand Up @@ -154,7 +155,8 @@ private PlaceholderRecord createPlaceholderRecord(final AbstractBinlogEvent even
}

private PipelineTableMetaData getPipelineTableMetaData(final String actualTableName) {
return metaDataLoader.getTableMetaData(dumperContext.getSchemaName(actualTableName), actualTableName);
LogicTableName logicTableName = dumperContext.getTableNameMapper().getLogicTableName(actualTableName);
return metaDataLoader.getTableMetaData(dumperContext.getTableAndSchemaNameMapper().getSchemaName(logicTableName), actualTableName);
}

private List<DataRecord> handleWriteRowsEvent(final WriteRowsEvent event, final PipelineTableMetaData tableMetaData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.PlaceholderRecord;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.Record;
import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
import org.apache.shardingsphere.data.pipeline.api.metadata.loader.PipelineTableMetaDataLoader;
import org.apache.shardingsphere.data.pipeline.api.metadata.model.PipelineColumnMetaData;
import org.apache.shardingsphere.data.pipeline.api.metadata.model.PipelineTableMetaData;
Expand Down Expand Up @@ -89,7 +90,8 @@ private PlaceholderRecord createPlaceholderRecord(final AbstractWALEvent event)
}

private PipelineTableMetaData getPipelineTableMetaData(final String actualTableName) {
return metaDataLoader.getTableMetaData(dumperContext.getSchemaName(actualTableName), actualTableName);
LogicTableName logicTableName = dumperContext.getTableNameMapper().getLogicTableName(actualTableName);
return metaDataLoader.getTableMetaData(dumperContext.getTableAndSchemaNameMapper().getSchemaName(logicTableName), actualTableName);
}

private DataRecord handleWriteRowEvent(final WriteRowEvent writeRowEvent, final PipelineTableMetaData tableMetaData) {
Expand Down

0 comments on commit c67ffd7

Please sign in to comment.