【问题标题】:Mapreduce with C#: Process whole input files使用 C# 的 Mapreduce:处理整个输入文件
【发布时间】:2016-02-03 11:00:39
【问题描述】:

问题:

我正在用 C# 为 HDInsight 创建一个 MapReduce 应用程序。我需要处理整个输入文件。

我了解,Hadoop 中有两个选项可以实现此目的:

  • 派生自 InputFormat 类,并始终让 isSplitable 返回错误
  • 将 min_splitsize 设置为足够大的值

我不知道如何在 HDInsight 上使用 C# 实现这些选项。

详情:

我也是

  • 使用 Microsoft.Hadoop.MapReduce,并通过 hadoop.MapReduceJob.ExecuteJob<MyJob>(); 启动作业

  • 或者通过简单地创建一个控制台应用程序并通过 azure powershell 启动它

    $mrJobDef = New-AzureHDInsightStreamingMapReduceJobDefinition -JobName MyJob -StatusFolder $mrStatusOutput -Mapper $mrMapper -Reducer $mrReducer -InputPath $mrInput -OutputPath $mrOutput

    $mrJobDef.Files.Add($mrMapperFile)

    $mrJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $mrJobDef

任何一种方式的解决方案都会有很大帮助。

【问题讨论】:

    标签: c# mapreduce hadoop-streaming azure-hdinsight


    【解决方案1】:

    可以在powershell中使用-Defines参数设置min_splitsize

    $clusterName = "YourClusterName"
    $jobConfig = @{ "min_splitsize"="512mb"; "mapred.output.compression.codec"="org.apache.hadoop.io.compress.GzipCodec" }
    $myWordCountJob = New-AzureHDInsightMapReduceJobDefinition -JarFile "/example/jars/hadoop-examples.jar" -ClassName "wordcount" -jobName "WordCountJob" -StatusFolder "/MyMRJobs/WordCountJobStatus" -Defines $jobConfig 
    

    或在 C# 中

        var mapReduceJob = new MapReduceJobCreateParameters() 
        {
              ClassName = "wordcount", // required
              JobName = "MyWordCountJob", //optional
              JarFile = "/example/jars/hadoop-examples.jar",  // Required, alternative syntax: wasb://hdijobs@azimasv2.blob.core.windows.net/example/jar/hadoop-examples.jar
              StatusFolder = "/AzimMRJobs/WordCountJobStatus" //Optional, but good to use to know where logs are uploaded in Azure Storage
        };
    
        mapReduceJob.Defines.Add("min_splitsize", "512mb");
    

    虽然我认为这不能保证每个文件都会被完全读取。为此,您可能需要此处说明的 Java SDK http://www.andrewsmoll.com/3-hacks-for-hadoop-and-hdinsight-clusters/

    资源: http://blogs.msdn.com/b/bigdatasupport/archive/2014/02/13/how-to-pass-hadoop-configuration-values-for-a-job-via-hdinsight-powershell-and-net-sdk.aspx

    【讨论】:

    • 安德鲁,谢谢,这听起来和我要找的完全一样。我只是需要一些时间来验证这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-25
    • 2010-10-15
    • 2012-09-28
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 2013-02-05
    相关资源
    最近更新 更多