Compile, Build, and Run the CountTableRows Example

After you have run the LoadVehicleTable program to create and populate the example vehicleTable (see the CountTableRows Support Programs appendix), but before you execute the example MapReduce job, you must first compile the CountTableRows program and package the compiled artifacts for deployment to the Hadoop infrastructure.

To compile the CountTableRows program, several Hadoop JAR files must be installed and available in your build environment for inclusion in the program classpath. Those JAR files are:
  • commons-logging-<version>.jar
  • hadoop-common-<version>.jar
  • hadoop-mapreduce-client-core-<version>.jar
  • hadoop-annotations-<version>.jar
  • hadoop-yarn-api-<version>.jar

The <version> token used above represents the particular version number of the corresponding JAR file contained in the Hadoop distribution installed in your build environment.

For example, suppose that the 3.0.0 version of Hadoop, packaged by Cloudera version 6.3.0 (cdh6.3.0), was installed on your system via parcels; where a parcel is a binary distribution format that Cloudera provides as an alternative to rpm/deb packages. Additionally, suppose that the classes from that version of Hadoop use the 1.1.3 version of commons-logging. Given these assumptions, to compile the CountTableRows program, you would then type the following at the command line:

cd /opt/oracle/nosql/apps/kv
javac -classpath \
    /opt/cloudera/parcels/CDH/jars/commons-logging-1.1.3.jar: \
    /opt/cloudera/parcels/CDH/jars/
        hadoop-common-3.0.0-cdh6.3.0.jar: \
    /opt/cloudera/parcels/CDH/jars/ \
        hadoop-mapreduce-client-core-3.0.0-cdh6.3.0.jar: \
    /opt/cloudera/parcels/CDH/jars/ \
        hadoop-annotations-3.0.0-cdh6.3.0.jar: \
    /opt/cloudera/parcels/CDH/jars/ \
        hadoop-yarn-api-3.0.0-cdh6.3.0.jar: \
    /opt/oracle/kv-ee/lib/kvclient.jar:examples \
        examples/hadoop/table/CountTableRows.java

This produces the following files:

/opt/oracle/nosql/apps/kv/examples/hadoop/table/
    CountTableRows.class
    CountTableRows$Map.class
    CountTableRows$Reduce.class

If your specific environment has a different, compatible Hadoop distribution installed, then simply replace the paths and version references in the example command line above with the appropriate values for your particular Hadoop installation.