MapReduce
在hadoop簇在运行之前MapReduce
在哈迪普上®cluster, make sure that the cluster and client machine are properly configured. Consult your system administrator, or see配置Hadoop群集(MATLAB Parallel Server)。
运行时MapReduce
在带有二进制输出的Hadoop群集上(默认)KeyValueDatastore
指向hadoop序列文件,而不是由二进制文件文件MapReduce
在其他环境中。有关更多信息,请参阅'outputType'
参数描述MapReduce
reference page.
运行时MapReduce
在哈迪普上cluster, the order of the key-value pairs in the output is different compared to runningMapReduce
在其他环境中。如果您的应用程序取决于输出中数据的布置,则必须根据自己的要求对数据进行排序。
此示例显示了如何修改MATLAB®计算平均航空公司延迟以在Hadoop群集上运行的示例。
首先,您必须将环境变量和群集属性设置为适合您的特定hadoop配置。有关这些和其他属性的值,请参阅您的系统管理员,将作业提交给您的集群所需的属性。
setenv('hadoop_home',,,,'/path/to/hadoop/install')cluster = Parallel.Cluster.hadoop;
创建一个MapReducer对象以指定MapReduce
should use your Hadoop cluster.
MR = MapReducer(cluster);
创建和预览数据存储。的数据集available in
。matlabroot
/工具箱/MATLAB/演示
ds = datastore('airlinesmall.csv',,,,“治疗”,,,,'na',,,,...“选择的variablenames”,,,,'arrdelay',,,,“读取尺寸”,1000);预览(DS)
Arrdelay ________ 8 8 21 13 4 59 3 11
接下来,指定输出文件夹,输出淘汰
并打电话MapReduce
在指定的hadoop群集上执行先生
。地图和减少功能可在
。matlabroot
/工具箱/MATLAB/演示
output -folder ='HDFS:/// Home/Myuser/out1';utds = mapreduce(ds,@mymapperfcn,@myreducerfcn,'导出目录',导出目录);sundelay = mapReduce(ds,@meanarrivalDelayMapper,@meanarrivalDelayreducer,MR,...'导出目录',导出目录)
Hadoop群集上的平行MapReduce执行:*************************************************************************************************************************************************地图0%减少0%地图66%减少0%地图100%减少66%地图100%减少100%sundelay = keyValueDatastore具有属性:文件:{'.../tmp/alafleur/tpc00621b1_4eef_4eef_4eef_4abc_8078_646a916e7d9/part0.7d9/part0.seq'}
阅读结果。
readall(sundelay)
钥匙值__________________ ________'MeanarrivalDelay'[7.1201]
尽管出于演示目的,此示例使用本地数据集,但使用Hadoop时,您的数据集可能存储在HDFS™文件系统中。同样,您可能需要存储MapReduce
在HDFS中输出。有关在MATLAB中访问HDFS的详细信息,请参阅使用远程数据。