diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/InventoryDumper.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/InventoryDumper.java index 09ba34b80aeaa..c48e7ae2b969e 100644 --- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/InventoryDumper.java +++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/InventoryDumper.java @@ -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) { @@ -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();