Я новичок в хаупе. Я хочу понять поток функции уменьшения карты. Я немного смущен тем, как мне ввести данные для задания карты через код, а не через какой-либо файл. Как мне его настроить. Пожалуйста, помогите мне. Вот мой код.
public class TemperatureMapper : MapperBase
{
private static int MISSING = 9999;
public override void Map(string line, MapperContext context)
{
//Extract the namespace declarations in the Csharp files
string year = line.Substring(15, 4);
int startIndex = line[87] == '+'?88 : 87;
int airTemp = int.Parse(line.Substring(startIndex, 92 - startIndex));
string quality = line.Substring(92, 1);
Regex r = new Regex(quality, RegexOptions.IgnoreCase);
Match m = r.Match("[01459]");
if (airTemp != MISSING && r.Match("[01459]").Success)
{
context.EmitKeyValue(year.ToString(), airTemp.ToString());
}
}
}
//Reducer
public class TempReducer : ReducerCombinerBase
{
//Accepts each key and count the occurrances
public override void Reduce(string key, IEnumerable<string> values,ReducerCombinerContext context)
{
//Write back
int maxvalue = int.MinValue;
foreach(string value in values)
{
maxvalue = Math.Max(maxvalue, int.Parse(value));
}
context.EmitKeyValue(key, maxvalue.ToString());
}
}
static void Main(string[] args)
{
try
{
string line;
StreamReader file = new StreamReader("temp.txt");
ArrayList al = new ArrayList();
while ((line = file.ReadLine()) != null)
{
al.Add(line);
}
file.Close();
string[] input = (string[])al.ToArray(typeof(string));
Environment.SetEnvironmentVariable("HADOOP_HOME", @"c:\hadoop");
Environment.SetEnvironmentVariable("Java_HOME", @"c:\hadoop\jvm");
var output = StreamingUnit.Execute<TemperatureMapper, TempReducer>(input);//this code is executed successfully
//runnning the job in azure
var hadoop = Hadoop.Connect(); // connected to hadoop successfully
var config = new HadoopJobConfiguration();
hadoop.MapReduceJob.Execute<TemperatureMapper, TempReducer>(config);//how to I provide input here...
Console.ReadLine();
}
Я получаю правильный результат через потоковое устройство. Теперь я хочу выполнить это задание в Azure. Итак, как мне вводить данные через код, а не через файлы? Я ввел данные через конфигурацию, т.е.
config.AdditionalStreamingArguments.AddRange(input); //input is array of string
но когда я выполняю задание, возникает это исключение:
The argument must not be empty string.
Parameter name: blobName