Skip to content

Commit

Permalink
Refactor InventoryDumper (#32636)
Browse files Browse the repository at this point in the history
* Move DatabaseTypeUtils

* Move DatabaseTypeUtils

* Move DatabaseTypeUtils

* Refactor InventoryDumper
  • Loading branch information
terrymanu authored Aug 22, 2024
1 parent 0ecc7d9 commit 93973e3
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ protected void runBlocking() {
}
init();
try (Connection connection = dataSource.getConnection()) {
if (!Strings.isNullOrEmpty(dumperContext.getQuerySQL()) || !dumperContext.hasUniqueKey() || isPrimaryKeyWithoutRanged(position)) {
dumpWithStreamingQuery(connection);
} else {
if (Strings.isNullOrEmpty(dumperContext.getQuerySQL()) && dumperContext.hasUniqueKey() && !isPrimaryKeyWithoutRange(position)) {
dumpPageByPage(connection);
} else {
dumpWithStreamingQuery(connection);
}
// CHECKSTYLE:OFF
} catch (final SQLException | RuntimeException ex) {
Expand All @@ -121,20 +121,17 @@ protected void runBlocking() {
}
}

private boolean isPrimaryKeyWithoutRanged(final IngestPosition position) {
return position instanceof PrimaryKeyIngestPosition && null == ((PrimaryKeyIngestPosition<?>) position).getBeginValue() && null == ((PrimaryKeyIngestPosition<?>) position).getEndValue();
}

/**
* Initialize.
*/
public void init() {
private void init() {
if (null == tableMetaData) {
tableMetaData = metaDataLoader.getTableMetaData(
dumperContext.getCommonContext().getTableAndSchemaNameMapper().getSchemaName(dumperContext.getLogicTableName()), dumperContext.getActualTableName());
}
}

private boolean isPrimaryKeyWithoutRange(final IngestPosition position) {
return position instanceof PrimaryKeyIngestPosition && null == ((PrimaryKeyIngestPosition<?>) position).getBeginValue() && null == ((PrimaryKeyIngestPosition<?>) position).getEndValue();
}

@SuppressWarnings("MagicConstant")
private void dumpWithStreamingQuery(final Connection connection) throws SQLException {
int batchSize = dumperContext.getBatchSize();
Expand Down

0 comments on commit 93973e3

Please sign in to comment.