KurtYoung commented on a change in pull request #10170: [FLINK-14722][hadoop]
Optimize mapred.HadoopInputSplit to not serialize conf when split is not
configurable
URL: https://github.com/apache/flink/pull/10170#discussion_r349454800
##########
File path:
flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/wrapper/HadoopInputSplit.java
##########
@@ -103,23 +109,28 @@ private void readObject(ObjectInputStream in) throws
IOException, ClassNotFoundE
// read the parent fields and the final fields
in.defaultReadObject();
- // the job conf knows how to deserialize itself
- jobConf = new JobConf();
- jobConf.readFields(in);
-
try {
hadoopInputSplit =
(org.apache.hadoop.mapred.InputSplit) WritableFactories.newInstance(splitType);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeException("Unable to instantiate
Hadoop InputSplit", e);
}
- if (hadoopInputSplit instanceof Configurable) {
- ((Configurable) hadoopInputSplit).setConf(this.jobConf);
- }
- else if (hadoopInputSplit instanceof JobConfigurable) {
- ((JobConfigurable)
hadoopInputSplit).configure(this.jobConf);
+ if (isConfigurable(hadoopInputSplit)) {
+ // the job conf knows how to deserialize itself
+ jobConf = new JobConf();
+ jobConf.readFields(in);
+
+ if (hadoopInputSplit instanceof Configurable) {
+ ((Configurable)
hadoopInputSplit).setConf(this.jobConf);
+ } else if (hadoopInputSplit instanceof JobConfigurable)
{
+ ((JobConfigurable)
hadoopInputSplit).configure(this.jobConf);
+ }
}
+
hadoopInputSplit.readFields(in);
}
+
+ private static boolean
isConfigurable(org.apache.hadoop.mapred.InputSplit split) {
Review comment:
change method name to `needsJobConf` might be more clear
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services