You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by tu...@apache.org on 2022/04/08 15:48:30 UTC
[shardingsphere] branch master updated: Rename ValueHandler to MySQLDataTypeHandler (#16685)
This is an automated email from the ASF dual-hosted git repository.
tuichenchuxin 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 ff5db0d9812 Rename ValueHandler to MySQLDataTypeHandler (#16685)
ff5db0d9812 is described below
commit ff5db0d9812d6eab2c6dd9e821175cbc31aa31e6
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Apr 8 23:48:22 2022 +0800
Rename ValueHandler to MySQLDataTypeHandler (#16685)
* Refactor ValueHandler to impl StatelessTypedSPI
* Rename ValueHandler to MySQLDataTypeHandler
---
.../mysql/ingest/MySQLIncrementalDumper.java | 20 ++++---------
...ValueHandler.java => MySQLDataTypeHandler.java} | 13 ++-------
...ndler.java => MySQLDataTypeHandlerFactory.java} | 33 ++++++++++++----------
.../MySQLUnsignedBigintHandler.java} | 19 ++++++++-----
.../MySQLUnsignedIntHandler.java} | 19 ++++++++-----
.../MySQLUnsignedMediumintHandler.java} | 19 ++++++++-----
.../MySQLUnsignedSmallintHandler.java} | 19 ++++++++-----
.../MySQLUnsignedTinyintHandler.java} | 19 ++++++++-----
...mysql.ingest.column.value.MySQLDataTypeHandler} | 10 +++----
...st.java => MySQLUnsignedBigintHandlerTest.java} | 5 ++--
...rTest.java => MySQLUnsignedIntHandlerTest.java} | 5 ++--
...java => MySQLUnsignedMediumintHandlerTest.java} | 5 ++--
....java => MySQLUnsignedSmallintHandlerTest.java} | 5 ++--
...t.java => MySQLUnsignedTinyintHandlerTest.java} | 5 ++--
14 files changed, 106 insertions(+), 90 deletions(-)
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
index ab0d1a37e5b..44f032272ae 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java
@@ -44,16 +44,15 @@ import org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event.UpdateR
import org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event.WriteRowsEvent;
import org.apache.shardingsphere.data.pipeline.mysql.ingest.client.ConnectInfo;
import org.apache.shardingsphere.data.pipeline.mysql.ingest.client.MySQLClient;
-import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.ValueHandler;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandlerFactory;
import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPIRegistry;
import java.io.Serializable;
import java.security.SecureRandom;
-import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Random;
/**
@@ -62,12 +61,6 @@ import java.util.Random;
@Slf4j
public final class MySQLIncrementalDumper extends AbstractIncrementalDumper<BinlogPosition> {
- static {
- ShardingSphereServiceLoader.register(ValueHandler.class);
- }
-
- private static final Map<String, ValueHandler> VALUE_HANDLER_MAP = SingletonSPIRegistry.getSingletonInstancesMap(ValueHandler.class, ValueHandler::getTypeName);
-
private final BinlogPosition binlogPosition;
private final DumperConfiguration dumperConfig;
@@ -177,11 +170,8 @@ public final class MySQLIncrementalDumper extends AbstractIncrementalDumper<Binl
}
private Serializable handleValue(final PipelineColumnMetaData columnMetaData, final Serializable value) {
- ValueHandler valueHandler = VALUE_HANDLER_MAP.get(columnMetaData.getDataTypeName());
- if (null != valueHandler) {
- return valueHandler.handle(value);
- }
- return value;
+ Optional<MySQLDataTypeHandler> dataTypeHandler = MySQLDataTypeHandlerFactory.newInstance(columnMetaData.getDataTypeName());
+ return dataTypeHandler.isPresent() ? dataTypeHandler.get().handle(value) : value;
}
private DataRecord createDataRecord(final AbstractRowsEvent rowsEvent, final int columnCount) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
similarity index 81%
copy from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java
copy to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
index 5a75ea03ad4..6d317f18266 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
@@ -17,21 +17,14 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
import java.io.Serializable;
/**
- * Value handler.
+ * MySQL data type handler.
*/
-public interface ValueHandler extends SingletonSPI {
-
- /**
- * Get support type name.
- *
- * @return type name
- */
- String getTypeName();
+public interface MySQLDataTypeHandler extends StatelessTypedSPI {
/**
* Handle column value.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandlerFactory.java
similarity index 53%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandlerFactory.java
index 5a75ea03ad4..0d567faaada 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/ValueHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandlerFactory.java
@@ -17,27 +17,30 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
-import java.io.Serializable;
+import java.util.Optional;
/**
- * Value handler.
+ * MySQL data type handler factory.
*/
-public interface ValueHandler extends SingletonSPI {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class MySQLDataTypeHandlerFactory {
- /**
- * Get support type name.
- *
- * @return type name
- */
- String getTypeName();
+ static {
+ ShardingSphereServiceLoader.register(MySQLDataTypeHandler.class);
+ }
/**
- * Handle column value.
- *
- * @param value column value
- * @return handled column value
+ * Create new instance of MySQL data type handler.
+ *
+ * @param dataTypeName data type name
+ * @return new instance of MySQL data type handler
*/
- Serializable handle(Serializable value);
+ public static Optional<MySQLDataTypeHandler> newInstance(final String dataTypeName) {
+ return TypedSPIRegistry.findRegisteredService(MySQLDataTypeHandler.class, dataTypeName);
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java
similarity index 83%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java
index ec40f1201aa..b17f8920903 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedBigintHandler.java
@@ -15,23 +15,28 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl;
+
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
import java.io.Serializable;
import java.math.BigInteger;
-public final class UnsignedBigintHandler implements ValueHandler {
+/**
+ * MySQL unsigned bigint handler.
+ */
+public final class MySQLUnsignedBigintHandler implements MySQLDataTypeHandler {
private static final BigInteger BIGINT_MODULO = new BigInteger("18446744073709551616");
- @Override
- public String getTypeName() {
- return "BIGINT UNSIGNED";
- }
-
@Override
public Serializable handle(final Serializable value) {
long longValue = (long) value;
return 0 > longValue ? BIGINT_MODULO.add(BigInteger.valueOf(longValue)) : longValue;
}
+
+ @Override
+ public String getType() {
+ return "BIGINT UNSIGNED";
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedIntHandler.java
similarity index 77%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedIntHandler.java
index 3ee5690e0c7..610913db874 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedIntHandler.java
@@ -15,22 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl;
+
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
import java.io.Serializable;
-public final class UnsignedIntHandler implements ValueHandler {
+/**
+ * MySQL unsigned int handler.
+ */
+public final class MySQLUnsignedIntHandler implements MySQLDataTypeHandler {
private static final long INT_MODULO = 4294967296L;
@Override
- public String getTypeName() {
- return "INT UNSIGNED";
+ public Serializable handle(final Serializable value) {
+ int intValue = (int) value;
+ return intValue < 0 ? INT_MODULO + intValue : intValue;
}
@Override
- public Serializable handle(final Serializable value) {
- int intValue = (int) value;
- return 0 > intValue ? INT_MODULO + intValue : intValue;
+ public String getType() {
+ return "INT UNSIGNED";
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedMediumintHandler.java
similarity index 81%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedMediumintHandler.java
index 7860388e9ad..85f394433d9 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedMediumintHandler.java
@@ -15,22 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl;
+
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
import java.io.Serializable;
-public final class UnsignedMediumintHandler implements ValueHandler {
+/**
+ * MySQL unsigned mediumint handler.
+ */
+public final class MySQLUnsignedMediumintHandler implements MySQLDataTypeHandler {
private static final int MEDIUMINT_MODULO = 16777216;
- @Override
- public String getTypeName() {
- return "MEDIUMINT UNSIGNED";
- }
-
@Override
public Serializable handle(final Serializable value) {
int intValue = (int) value;
return 0 > intValue ? MEDIUMINT_MODULO + intValue : intValue;
}
+
+ @Override
+ public String getType() {
+ return "MEDIUMINT UNSIGNED";
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedSmallintHandler.java
similarity index 82%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedSmallintHandler.java
index f9f3cff0530..8dc9435e46d 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedSmallintHandler.java
@@ -15,22 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl;
+
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
import java.io.Serializable;
-public final class UnsignedSmallintHandler implements ValueHandler {
+/**
+ * MySQL unsigned smallint handler.
+ */
+public final class MySQLUnsignedSmallintHandler implements MySQLDataTypeHandler {
private static final int SMALLINT_MODULO = 65536;
- @Override
- public String getTypeName() {
- return "SMALLINT UNSIGNED";
- }
-
@Override
public Serializable handle(final Serializable value) {
short shortValue = (short) value;
return 0 > shortValue ? SMALLINT_MODULO + shortValue : shortValue;
}
+
+ @Override
+ public String getType() {
+ return "SMALLINT UNSIGNED";
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedTinyintHandler.java
similarity index 81%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandler.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedTinyintHandler.java
index fba995af6cc..b6f51428dde 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/impl/MySQLUnsignedTinyintHandler.java
@@ -15,22 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl;
+
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler;
import java.io.Serializable;
-public final class UnsignedTinyintHandler implements ValueHandler {
+/**
+ * MySQL unsigned tinyint handler.
+ */
+public final class MySQLUnsignedTinyintHandler implements MySQLDataTypeHandler {
private static final int TINYINT_MODULO = 256;
- @Override
- public String getTypeName() {
- return "TINYINT UNSIGNED";
- }
-
@Override
public Serializable handle(final Serializable value) {
byte byteValue = (byte) value;
return 0 > byteValue ? TINYINT_MODULO + byteValue : byteValue;
}
+
+ @Override
+ public String getType() {
+ return "TINYINT UNSIGNED";
+ }
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.ValueHandler b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler
similarity index 86%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.ValueHandler
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler
index c775757a34f..a68963130f0 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.ValueHandler
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.MySQLDataTypeHandler
@@ -15,8 +15,8 @@
# limitations under the License.
#
-org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.UnsignedTinyintHandler
-org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.UnsignedSmallintHandler
-org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.UnsignedMediumintHandler
-org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.UnsignedIntHandler
-org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.UnsignedBigintHandler
+org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedTinyintHandler
+org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedSmallintHandler
+org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedMediumintHandler
+org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedIntHandler
+org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedBigintHandler
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandlerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedBigintHandlerTest.java
similarity index 84%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandlerTest.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedBigintHandlerTest.java
index f605b02a732..5fffb7653c9 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedBigintHandlerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedBigintHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedBigintHandler;
import org.junit.Test;
import java.io.Serializable;
@@ -25,9 +26,9 @@ import java.math.BigInteger;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class UnsignedBigintHandlerTest {
+public final class MySQLUnsignedBigintHandlerTest {
- private final UnsignedBigintHandler handler = new UnsignedBigintHandler();
+ private final MySQLUnsignedBigintHandler handler = new MySQLUnsignedBigintHandler();
@Test
public void assertHandle() {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandlerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedIntHandlerTest.java
similarity index 84%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandlerTest.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedIntHandlerTest.java
index 9befdabaacc..f65faabd2f2 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedIntHandlerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedIntHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedIntHandler;
import org.junit.Test;
import java.io.Serializable;
@@ -24,9 +25,9 @@ import java.io.Serializable;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class UnsignedIntHandlerTest {
+public final class MySQLUnsignedIntHandlerTest {
- private final UnsignedIntHandler handler = new UnsignedIntHandler();
+ private final MySQLUnsignedIntHandler handler = new MySQLUnsignedIntHandler();
@Test
public void assertHandle() {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandlerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedMediumintHandlerTest.java
similarity index 82%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandlerTest.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedMediumintHandlerTest.java
index e3b73ceff23..456bda67bb5 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedMediumintHandlerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedMediumintHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedMediumintHandler;
import org.junit.Test;
import java.io.Serializable;
@@ -24,9 +25,9 @@ import java.io.Serializable;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class UnsignedMediumintHandlerTest {
+public final class MySQLUnsignedMediumintHandlerTest {
- private final UnsignedMediumintHandler handler = new UnsignedMediumintHandler();
+ private final MySQLUnsignedMediumintHandler handler = new MySQLUnsignedMediumintHandler();
@Test
public void assertHandle() {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandlerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedSmallintHandlerTest.java
similarity index 83%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandlerTest.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedSmallintHandlerTest.java
index 190967efa58..e77e43a0d1f 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedSmallintHandlerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedSmallintHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedSmallintHandler;
import org.junit.Test;
import java.io.Serializable;
@@ -24,9 +25,9 @@ import java.io.Serializable;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class UnsignedSmallintHandlerTest {
+public final class MySQLUnsignedSmallintHandlerTest {
- private final UnsignedSmallintHandler handler = new UnsignedSmallintHandler();
+ private final MySQLUnsignedSmallintHandler handler = new MySQLUnsignedSmallintHandler();
@Test
public void assertHandle() {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandlerTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedTinyintHandlerTest.java
similarity index 83%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandlerTest.java
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedTinyintHandlerTest.java
index fa5f4822f2e..7ef82da54dc 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/UnsignedTinyintHandlerTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLUnsignedTinyintHandlerTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
+import org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value.impl.MySQLUnsignedTinyintHandler;
import org.junit.Test;
import java.io.Serializable;
@@ -24,9 +25,9 @@ import java.io.Serializable;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class UnsignedTinyintHandlerTest {
+public final class MySQLUnsignedTinyintHandlerTest {
- private final UnsignedTinyintHandler handler = new UnsignedTinyintHandler();
+ private final MySQLUnsignedTinyintHandler handler = new MySQLUnsignedTinyintHandler();
@Test
public void assertHandle() {