Guest User

streaminginput

a guest
Jun 22nd, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Hadoop.MapReduce;
  6.  
  7. namespace mapreduce {
  8. public class Program : HadoopJob<MyMapper> {
  9. static void Main(string[] args) {
  10. string[] input;
  11. if (args.Length < 2) {
  12. input = args;
  13. }
  14. else {
  15. input = new string[]
  16. {
  17. "1, a",
  18. "1, b",
  19. "2, c",
  20. "2, d",
  21. "3, e",
  22. "4, f"
  23. };
  24. }
  25. var output = StreamingUnit.Execute<MyMapper, MyReducer>(input);
  26. var result = output.Result.ToList();
  27. var mapperresult = output.MapperResult.ToList();
  28. }
  29.  
  30. public override HadoopJobConfiguration Configure(ExecutorContext context) {
  31. HadoopJobConfiguration config = new HadoopJobConfiguration();
  32.  
  33. config.InputPath ="input/SqrtJob";
  34. config.OutputFolder = "output/SqrtJob";
  35. return config;
  36. }
  37. }
  38.  
  39.  
  40.  
  41. public class MyMapper : MapperBase {
  42. public override void Map(string inputLine, MapperContext context) {
  43. context.Log("mapper called. input=" + inputLine);
  44. context.IncrementCounter("mapInputs");
  45. context.EmitKeyValue("key!", "value!");
  46. }
  47. }
  48.  
  49. public class MyReducer : ReducerCombinerBase {
  50. public override void Reduce(string key, IEnumerable<string> values, ReducerCombinerContext context) {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. }
Add Comment
Please, Sign In to add comment