Method Map
Map(Object, Object, IOutputMap)
This method will contain the logic to map the input from cache into more meaningful and goal specific key-value pairs which can be sent to the Reducer or optional Combiner.
Referring to the workflow diagram, the string input is transformed by emitting each word with a key-value pair in the Mapper.
Declaration
void Map(object key, object value, IOutputMap context)
Parameters
Type | Name | Description |
---|---|---|
System.Object | key | Key value of cache Entry. |
System.Object | value | Value for the key |
IOutputMap | context | Emitted output value for each key-value pair |
Examples
Following example demonstrate the usage of Map.
string[] parsedline;
string line;
public void Map(Object key, Object value, IOutputMap context)
{
line = value.ToString();
parsedline = line.Split(' ');
for (int i = parsedline.Length; i>=0; i++)
{
context.Emit(parsedline[i], 1);
}
}