Sie sind auf Seite 1von 2

Java Code:

package AS400.HiveUDF;

import org.apache.hadoop.hive.ql.exec.UDF;

import com.ibm.as400.access.AS400Text;

public class CovertThai extends UDF {


public String evaluate(String inputStr) {
String returnValue = null;
int sourceCCSID = 838;
String encodingType = "CP037";

try {
if (inputStr != null && !("").equals(inputStr)) {
AS400Text text = new com.ibm.as400.access.AS400Text(inputStr.length(), sourceCCSID);
Object stringObj = text.toObject(inputStr.getBytes(encodingType));
returnValue = stringObj.toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
}

Pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>AS400</groupId>
<artifactId>HiveUDF</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<repositories>
<repository>
<id>public</id>
<url>https://repo.hortonworks.com/content/repositories/releases/</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.8.0_191</version>
<scope>system</scope>
<systemPath>C:/Program Files/Java/jdk1.8.0_191/lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>2.1.1</version>
</dependency>
<!-- <dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400</artifactId>
<version>6.6</version>
</dependency>-->
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400-jdk8</artifactId>
<version>9.7</version>
</dependency>

</dependencies>

<build>
<plugins>
<!-- Maven Assembly Plugin -->

Dell Customer Communication - Confidential


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>AS400.HiveUDF.CovertThai</mainClass>
</manifest>
</archive>

</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</build>
</project>

Jar file location:

[HDFS LOCATION] hdfs:/user/hive/HiveUDF-0.0.1-SNAPSHOT-jar-with-dependencies.jar

OR

[LOCAL LOCATION] /home/fwdguest12/HiveUDF-0.0.1-SNAPSHOT-jar-with-dependencies.jar

Dell Customer Communication - Confidential

Das könnte Ihnen auch gefallen