Running MapReduce Applications
About this task
HCatalogMRTest.java. Procedure
-
From the command line, issue the following commands to define the environment:
export LIB_JARS= $HCAT_HOME/share/hcatalog/hcatalog-core-<version>-mapr.jar, $HIVE_HOME/lib/hive-metastore-<version>-mapr.jar, $HIVE_HOME/lib/libthrift-<version>.jar, $HIVE_HOME/lib/hive-exec-<version>-mapr.jar, $HIVE_HOME/lib/libfb303-<version>.jar, $HIVE_HOME/lib/jdo2-api-<version>-ec.jar, $HIVE_HOME/lib/slf4j-api-<version>.jar export HADOOP_CLASSPATH= $HCAT_HOME/share/hcatalog/hcatalog-core-<version>-mapr.jar: $HIVE_HOME/lib/hive-metastore-<version>-mapr.jar: $HIVE_HOME/lib/libthrift-<version>.jar: $HIVE_HOME/lib/hive-exec-<version>-mapr.jar: $HIVE_HOME/lib/libfb303-<version>.jar: $HIVE_HOME/lib/jdo2-api-<version>-ec.jar: $HIVE_HOME/conf: $HADOOP_HOME/conf: $HIVE_HOME/lib/slf4j-api-<version>.jar -
Compile
HCatalogMRTest.java:javac -cp `hadoop classpath`:${HCAT_HOME}/share/hcatalog/hcatalog-core-<version>-mapr.jar HCatalogMRTest.java -d . -
Create a JAR file:
jar -cf hcatmrtest.jar org -
Create an output table:
hcat -e "create table hcatpigoutput(key int, value int)" -
Run the job: At the end of the job, the file
hcatpigoutputshould have entries in the formkey, count.hadoop --config $HADOOP_HOME/conf jar ./hcatmrtest.jar org.myorg.HCatalogMRTest -libjars $LIB_JARS hcatpig hcatpigoutput