-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into mergeUpstream
# Conflicts: # tdenginereader/pom.xml # tdenginewriter/pom.xml # tdenginewriter/src/main/java/com/alibaba/datax/plugin/writer/tdenginewriter/DefaultDataHandler.java
- Loading branch information
Showing
176 changed files
with
8,633 additions
and
2,514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
core/src/main/java/com/alibaba/datax/core/transport/transformer/DigestTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.alibaba.datax.core.transport.transformer; | ||
|
||
import com.alibaba.datax.common.element.Column; | ||
import com.alibaba.datax.common.element.Record; | ||
import com.alibaba.datax.common.element.StringColumn; | ||
import com.alibaba.datax.common.exception.DataXException; | ||
import com.alibaba.datax.transformer.Transformer; | ||
|
||
import org.apache.commons.codec.digest.DigestUtils; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* no comments. | ||
* | ||
* @author XuDaojie | ||
* @since 2021-08-16 | ||
*/ | ||
public class DigestTransformer extends Transformer { | ||
|
||
private static final String MD5 = "md5"; | ||
private static final String SHA1 = "sha1"; | ||
private static final String TO_UPPER_CASE = "toUpperCase"; | ||
private static final String TO_LOWER_CASE = "toLowerCase"; | ||
|
||
public DigestTransformer() { | ||
setTransformerName("dx_digest"); | ||
} | ||
|
||
@Override | ||
public Record evaluate(Record record, Object... paras) { | ||
|
||
int columnIndex; | ||
String type; | ||
String charType; | ||
|
||
try { | ||
if (paras.length != 3) { | ||
throw new RuntimeException("dx_digest paras length must be 3"); | ||
} | ||
|
||
columnIndex = (Integer) paras[0]; | ||
type = (String) paras[1]; | ||
charType = (String) paras[2]; | ||
|
||
if (!StringUtils.equalsIgnoreCase(MD5, type) && !StringUtils.equalsIgnoreCase(SHA1, type)) { | ||
throw new RuntimeException("dx_digest paras index 1 must be md5 or sha1"); | ||
} | ||
if (!StringUtils.equalsIgnoreCase(TO_UPPER_CASE, charType) && !StringUtils.equalsIgnoreCase(TO_LOWER_CASE, charType)) { | ||
throw new RuntimeException("dx_digest paras index 2 must be toUpperCase or toLowerCase"); | ||
} | ||
} catch (Exception e) { | ||
throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras) + " => " + e.getMessage()); | ||
} | ||
|
||
Column column = record.getColumn(columnIndex); | ||
|
||
try { | ||
String oriValue = column.asString(); | ||
|
||
// 如果字段为空,作为空字符串处理 | ||
if (oriValue == null) { | ||
oriValue = ""; | ||
} | ||
String newValue; | ||
if (MD5.equals(type)) { | ||
newValue = DigestUtils.md5Hex(oriValue); | ||
} else { | ||
newValue = DigestUtils.sha1Hex(oriValue); | ||
} | ||
|
||
if (TO_UPPER_CASE.equals(charType)) { | ||
newValue = newValue.toUpperCase(); | ||
} else { | ||
newValue = newValue.toLowerCase(); | ||
} | ||
|
||
record.setColumn(columnIndex, new StringColumn(newValue)); | ||
|
||
} catch (Exception e) { | ||
throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e); | ||
} | ||
return record; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...c/main/java/com/alibaba/datax/core/transport/transformer/GroovyTransformerStaticUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package com.alibaba.datax.core.transport.transformer; | ||
|
||
import org.apache.commons.codec.digest.DigestUtils; | ||
|
||
/** | ||
* GroovyTransformer的帮助类,供groovy代码使用,必须全是static的方法 | ||
* Created by liqiang on 16/3/4. | ||
*/ | ||
public class GroovyTransformerStaticUtil { | ||
|
||
public static String md5(final String data) { | ||
return DigestUtils.md5Hex(data); | ||
} | ||
|
||
public static String sha1(final String data) { | ||
return DigestUtils.sha1Hex(data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"job": { | ||
"setting": { | ||
"speed": { | ||
"byte":10485760 | ||
"channel":1 | ||
}, | ||
"errorLimit": { | ||
"record": 0, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>datax-all</artifactId> | ||
<groupId>com.alibaba.datax</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>datahubreader</artifactId> | ||
|
||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.alibaba.datax</groupId> | ||
<artifactId>datax-common</artifactId> | ||
<version>${datax-project-version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<groupId>org.slf4j</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.aliyun.datahub</groupId> | ||
<artifactId>aliyun-sdk-datahub</artifactId> | ||
<version>2.21.6-public</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- compiler plugin --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${jdk-version}</source> | ||
<target>${jdk-version}</target> | ||
<encoding>${project-sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<!-- assembly plugin --> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>src/main/assembly/package.xml</descriptor> | ||
</descriptors> | ||
<finalName>datax</finalName> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>dwzip</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> | ||
<id></id> | ||
<formats> | ||
<format>dir</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>plugin.json</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/datahubreader</outputDirectory> | ||
</fileSet> | ||
<fileSet> | ||
<directory>target/</directory> | ||
<includes> | ||
<include>datahubreader-0.0.1-SNAPSHOT.jar</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/datahubreader</outputDirectory> | ||
</fileSet> | ||
</fileSets> | ||
|
||
<dependencySets> | ||
<dependencySet> | ||
<useProjectArtifact>false</useProjectArtifact> | ||
<outputDirectory>plugin/reader/datahubreader/libs</outputDirectory> | ||
<scope>runtime</scope> | ||
</dependencySet> | ||
</dependencySets> | ||
</assembly> |
8 changes: 8 additions & 0 deletions
8
datahubreader/src/main/java/com/alibaba/datax/plugin/reader/datahubreader/Constant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.alibaba.datax.plugin.reader.datahubreader; | ||
|
||
public class Constant { | ||
|
||
public static String DATETIME_FORMAT = "yyyyMMddHHmmss"; | ||
public static String DATE_FORMAT = "yyyyMMdd"; | ||
|
||
} |
Oops, something went wrong.