Note

If you forget setting the HADOOP_PREFIX environment variable prior to starting MATLAB, set it up using the MATLAB function setenv at the MATLAB command prompt as soon as you start MATLAB. For example:

setenv('HADOOP_PREFIX','/usr/lib/hadoop')

Install the MATLAB Runtime in a folder that is accessible by every worker node in the Hadoop cluster. This example uses
/usr/local/MATLAB/MATLAB_Runtime/v96 as the location of the MATLAB Runtime folder.

Note

Specifying a MATLAB Runtime location as part of the class
matlab.mapreduce.DeployHadoopMapReducer will
override any MATLAB Runtime location specified during the execution of the
standalone application.

Note

An HDFS directory such as .../myresults can
be written to only once. If you plan on running your standalone
application multiple times against the Hadoop cluster, make sure you delete the
.../myresults directory on HDFS prior to each execution. Another option is to change
the name of the .../myresults directory in the
MATLAB code and recompile the application.

Read the result from the resulting datastore.

myAppResult = readall(result)

Use the mcc command with the -m
flag to create a standalone application.

mcc -mdepMapRedStandAlone.m

The -m flag creates a standard executable that can
be run from a command line. However, the mcc command
cannot package the results in an installer.

Run the standalone application from a Linux shell using the following command:

$ ./run_depMapRedStandAlone.sh /usr/local/MATLAB/MATLAB_Runtime/v96

/usr/local/MATLAB/MATLAB_Runtime/v96 is an argument indicating the location of
the MATLAB Runtime.

Prior to executing the above command, verify that the
HADOOP_PREFIX environment variable is set in the
Terminal by typing:

$ echo $HADOOP_PREFIX

If
echo comes up empty, see the Prerequisites section above to see how you
can set the HADOOP_PREFIX environment
variable.

Your application will fail to execute if the
HADOOP_PREFIX environment variable is not
set.

Other examples of map and reduce
functions are available at toolbox/matlab/demos folder. You
can use other examples to prototype similar standalone applications that run
against Hadoop. For more information, see Build Effective Algorithms with MapReduce (MATLAB).

Complete code for the standalone application
depMapRedStandAlone can be found here: