diff --git a/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/Constant.java b/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/Constant.java new file mode 100644 index 0000000000..087f2173fe --- /dev/null +++ b/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/Constant.java @@ -0,0 +1,7 @@ +package com.alibaba.datax.plugin.reader.hanareader; + +public class Constant { + + public static final int DEFAULT_FETCH_SIZE = 1000; + +} \ No newline at end of file diff --git a/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/HanaReader.java b/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/HanaReader.java index a23cd58be2..7d6c914e41 100644 --- a/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/HanaReader.java +++ b/hanareader/src/main/java/com/alibaba/datax/plugin/reader/hanareader/HanaReader.java @@ -1,9 +1,11 @@ package com.alibaba.datax.plugin.reader.hanareader; +import com.alibaba.datax.common.exception.DataXException; import com.alibaba.datax.common.plugin.RecordSender; import com.alibaba.datax.common.spi.Reader; import com.alibaba.datax.common.util.Configuration; import com.alibaba.datax.plugin.rdbms.reader.CommonRdbmsReader; +import com.alibaba.datax.plugin.rdbms.util.DBUtilErrorCode; import com.alibaba.datax.plugin.rdbms.util.DataBaseType; import java.util.List; @@ -19,6 +21,14 @@ public static class Job extends Reader.Job { @Override public void init() { this.jobConfig = super.getPluginJobConf(); + int fetchSize = this.jobConfig.getInt(com.alibaba.datax.plugin.rdbms.reader.Constant.FETCH_SIZE, + Constant.DEFAULT_FETCH_SIZE); + if (fetchSize < 1) { + throw DataXException.asDataXException(DBUtilErrorCode.REQUIRED_VALUE, + String.format("您配置的fetchSize有误,根据DataX的设计,fetchSize : [%d] 设置值不能小于 1.", fetchSize)); + } + this.jobConfig.set(com.alibaba.datax.plugin.rdbms.reader.Constant.FETCH_SIZE, fetchSize); + this.commonRdbmsReaderMaster = new CommonRdbmsReader.Job(DATABASE_TYPE); this.commonRdbmsReaderMaster.init(this.jobConfig); } @@ -53,7 +63,7 @@ public void init() { @Override public void startRead(RecordSender recordSender) { - int fetchSize = this.jobConfig.getInt(com.alibaba.datax.plugin.rdbms.reader.Constant.FETCH_SIZE, 1000); + int fetchSize = this.jobConfig.getInt(com.alibaba.datax.plugin.rdbms.reader.Constant.FETCH_SIZE, Constant.DEFAULT_FETCH_SIZE); this.commonRdbmsReaderSlave.startRead(this.jobConfig, recordSender, super.getTaskPluginCollector(), fetchSize); }