This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 93973e3cd65 Refactor InventoryDumper (#32636)
93973e3cd65 is described below
commit 93973e3cd65454010e54901ace8f4b9e43196506
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 23 01:25:26 2024 +0800
Refactor InventoryDumper (#32636)
* Move DatabaseTypeUtils
* Move DatabaseTypeUtils
* Move DatabaseTypeUtils
* Refactor InventoryDumper
---
.../core/ingest/dumper/inventory/InventoryDumper.java | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
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 09ba34b80ae..c48e7ae2b96 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 @@ public class InventoryDumper extends
AbstractPipelineLifecycleRunnable implement
}
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 @@ public class InventoryDumper extends
AbstractPipelineLifecycleRunnable implement
}
}
- 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();