Github user fhueske commented on the pull request:
https://github.com/apache/incubator-flink/pull/37#issuecomment-49999194
I checked whether a MapFunction can be configured using a custom key in the
JobConf.
The following code does not work correctly (for multiple reasons):
```{java}
public class MyMapper implements Mapper<LongWritable, Text, IntWritable,
IntWritable> {
int x = 0;
@Override
public void configure(JobConf arg0) {
x = arg0.getInt("myX", 100);
System.out.println("x="+x);
}
@Override
public void map(LongWritable arg0, Text arg1,
OutputCollector<IntWritable, IntWritable> arg2, Reporter arg3)
throws IOException {
System.out.println("map x="+x);
}
}
public class MyStupidHadoopJob {
public static void main(String[] args) throws Exception {
final JobConf conf = new JobConf();
conf.setInputFormat(org.apache.hadoop.mapred.TextInputFormat.class);
org.apache.hadoop.mapred.TextInputFormat.addInputPath(conf, new
Path(...));
conf.setOutputFormat(TextOutputFormat.class);
TextOutputFormat.setOutputPath(conf, new Path(...));
conf.setMapperClass(MyMapper.class);
conf.setMapOutputKeyClass(IntWritable.class);
conf.setMapOutputValueClass(IntWritable.class);
conf.setInt("myX", 50);
conf.set("mapred.textoutputformat.separator", " ");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(LongWritable.class);
FlinkHadoopJobClient.runJob(conf);
}
}
```
I found the following:
- The `configure()` method is called (twice for DOP=1), i.e., the
`println()` is executed.
- The JobConf object passed to `configure()` seems to be incorrect. `x` is
assigned 100, i.e., the key `"myX"` is not set in the passed configuration.
- When executing the mapper, the `println()` statements print "map x=0",
i.e., `x` is not initialized in MapFunction instances which are called.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---