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_r349455337
 
 

 ##########
 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);
 
 Review comment:
   Is it ok to `conf` this `hadoopInputSplit` before 
`hadoopInputSplit.readFields(in)`? Looks dangerous to me. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to