带有C#/.NET的Hadoop

带有C#/.NET的Hadoop,hadoop,Hadoop,我发现Hadoop可以与C#()配合使用,但这种支持有多成熟?我可以在生产中使用它,还是最好使用一些JVM语言?您需要使用hadoop streaming jar来实现这一点。此外,应使用Microsoft.NET Map Reduce API For Hadoop编写c#中的程序 下面的所有代码都来自下面,它还有明确的构建和执行步骤 using Microsoft.Hadoop.MapReduce; using System; using System.Collections.Generic;

我发现Hadoop可以与C#()配合使用,但这种支持有多成熟?我可以在生产中使用它,还是最好使用一些JVM语言?

您需要使用hadoop streaming jar来实现这一点。此外,应使用Microsoft.NET Map Reduce API For Hadoop编写c#中的程序

下面的所有代码都来自下面,它还有明确的构建和执行步骤

using Microsoft.Hadoop.MapReduce;
using System;
using System.Collections.Generic;

namespace HadoopExploration
{
    class WordCount
    {
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                throw new ArgumentException("Usage: WordCount <input path> <output folder>");
            }
            HadoopJobConfiguration jobConfig = new HadoopJobConfiguration()
            {
                InputPath = args[0],
                OutputFolder = args[1],
                DeleteOutputFolder = true
            };
            Hadoop.Connect().MapReduceJob.Execute<WordMapper, SumReducer>(jobConfig);
        }
    }
}
using Microsoft.Hadoop.MapReduce;
    using System;
    using System.Collections.Generic;

    namespace HadoopExploration
    {
        public class WordMapper : MapperBase
        {
            public override void Map(string inputLine, MapperContext context)
            {
                char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
                //split up the passed in line
                string[] individualWords = inputLine.Trim().Split(delimiterChars);
                //write output KVP for each one of these
                foreach (string word in individualWords)
                {
                    context.EmitKeyValue(word.ToLower(), "1");
                }
            }
        }
    }

using Microsoft.Hadoop.MapReduce;
using System;
using System.Collections.Generic;

namespace HadoopExploration
{
    public class SumReducer : ReducerCombinerBase
    {
        public override void Reduce(string key, IEnumerable<string> values, ReducerCombinerContext context)
        {
            int wordCount = 0;
            //iterate through the count values passed to us by the mapper
            foreach (string countAsString in values)
            {
                wordCount += Int32.Parse(countAsString);
            }
            //write output "answer" as a KVP
            context.EmitKeyValue(key, Convert.ToString(wordCount));
        }
    }
}
使用Microsoft.Hadoop.MapReduce;
使用制度;
使用System.Collections.Generic;
名称空间Hadoop探索
{
类字数
{
静态void Main(字符串[]参数)
{
如果(参数长度!=2)
{
抛出新ArgumentException(“用法:WordCount”);
}
HadoopJobConfiguration jobConfig=新的HadoopJobConfiguration()
{
InputPath=args[0],
OutputFolder=args[1],
DeleteOutputFolder=true
};
Hadoop.Connect().MapReduceJob.Execute(jobConfig);
}
}
}
使用Microsoft.Hadoop.MapReduce;
使用制度;
使用System.Collections.Generic;
名称空间Hadoop探索
{
公共类WordMapper:MapperBase
{
公共覆盖无效映射(字符串输入行,MapperContext上下文)
{
char[]delimiterChars={',',',',':','\t'};
//把经过的队伍分开
string[]individualWords=inputLine.Trim().Split(delimiterCars);
//为其中的每一个写入输出KVP
foreach(单个单词中的字符串单词)
{
context.EmitKeyValue(word.ToLower(),“1”);
}
}
}
}
使用Microsoft.Hadoop.MapReduce;
使用制度;
使用System.Collections.Generic;
名称空间Hadoop探索
{
公共类SumReducer:ReducerCombinerBase
{
公共重写void Reduce(字符串键、IEnumerable值、ReducerCombinerContext上下文)
{
int字数=0;
//遍历映射程序传递给我们的计数值
foreach(字符串计数字符串值)
{
wordCount+=Int32.Parse(countAsString);
}
//将输出“应答”写入KVP
EmitKeyValue(key,Convert.ToString(wordCount));
}
}
}

我建议对Hadoop使用
java
python