0
次のコードは、ストリーミングジョブをクラスタに送信するために問題なく動作します。C#でキーとなるファイル名を取得バイナリmapper.exeとreducer.exeを使用してストリーミングmapreduceジョブ
string statusFolderName = @"/tutorials/wordcountstreaming/status";
var jobcred = new BasicAuthCredential();
jobcred.UserName = "username";
jobcred.Password = "pass";
jobcred.Server = new Uri("https://something.azurehdinsight.net");
// Define the Hadoop streaming MapReduce job
StreamingMapReduceJobCreateParameters myJobDefinition = new StreamingMapReduceJobCreateParameters()
{
JobName = "my word counting job",
StatusFolder = statusFolderName,
Input = "/example/data/gutenberg/davinci.txt",
Output = "/tutorials/wordcountstreaming/output",
Reducer = "wc.exe",
Mapper = "cat.exe"
};
myJobDefinition.Files.Add("/example/apps/wc.exe");
myJobDefinition.Files.Add("/example/apps/cat.exe");
var jobClient = JobSubmissionClientFactory.Connect(jobcred);
// Run the MapReduce job
JobCreationResults mrJobResults = jobClient.CreateStreamingJob(myJobDefinition);
----------------------マッパー-------------------- -------
namespace wc
{
class wc
{
static void Main(string[] args)
{
string line;
var count = 0;
if (args.Length > 0)
{
Console.SetIn(new StreamReader(args[0]));
}
while ((line = Console.ReadLine()) != null)
{
count += line.Count(cr => (cr == ' ' || cr == '\n'));
}
Console.WriteLine(count);
}
}
}
テキストファイルの名前をキーとして取得するにはどうすればよいですか? 出力にキー値を表示します。キーはファイルの名前で、値はファイル内の単語の数です 私は複数のファイルを持っています。
ありがとうございます。私はこれをテストし、出力を知り、それを受け入れます。 – NAS