pnowojski commented on a change in pull request #13234:
URL: https://github.com/apache/flink/pull/13234#discussion_r478490967



##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamConfig.java
##########
@@ -160,81 +159,84 @@ public TimeCharacteristic getTimeCharacteristic() {
                }
        }
 
-       public void setTypeSerializersIn(TypeSerializer<?> ...serializers) {
-               config.setInteger(TYPE_SERIALIZERS_IN_COUNT, 
serializers.length);
-               for (int i = 0; i < serializers.length; i++) {
-                       
setTypeSerializer(String.format(TYPE_SERIALIZERS_IN_PATTERN, i), 
serializers[i]);
-               }
-       }
-
        public void setTypeSerializerOut(TypeSerializer<?> serializer) {
                setTypeSerializer(TYPE_SERIALIZER_OUT_1, serializer);
        }
 
+       public <T> TypeSerializer<T> getTypeSerializerOut(ClassLoader cl) {
+               try {
+                       return 
InstantiationUtil.readObjectFromConfig(this.config, TYPE_SERIALIZER_OUT_1, cl);
+               } catch (Exception e) {
+                       throw new StreamTaskException("Could not instantiate 
serializer.", e);
+               }
+       }
+
        public void setTypeSerializerSideOut(OutputTag<?> outputTag, 
TypeSerializer<?> serializer) {
                setTypeSerializer(TYPE_SERIALIZER_SIDEOUT_PREFIX + 
outputTag.getId(), serializer);
        }
 
-       @Deprecated
-       public <T> TypeSerializer<T> getTypeSerializerIn1(ClassLoader cl) {
-               return getTypeSerializerIn(0, cl);
+       private void setTypeSerializer(String key, TypeSerializer<?> 
typeWrapper) {
+               try {
+                       InstantiationUtil.writeObjectToConfig(typeWrapper, 
this.config, key);
+               } catch (IOException e) {
+                       throw new StreamTaskException("Could not serialize type 
serializer.", e);
+               }
        }
 
-       @Deprecated
-       public <T> TypeSerializer<T> getTypeSerializerIn2(ClassLoader cl) {
-               return getTypeSerializerIn(1, cl);
+       public <T> TypeSerializer<T> getTypeSerializerSideOut(OutputTag<?> 
outputTag, ClassLoader cl) {
+               Preconditions.checkNotNull(outputTag, "Side output id must not 
be null.");
+               try {
+                       return 
InstantiationUtil.readObjectFromConfig(this.config, 
TYPE_SERIALIZER_SIDEOUT_PREFIX + outputTag.getId(), cl);
+               } catch (Exception e) {
+                       throw new StreamTaskException("Could not instantiate 
serializer.", e);
+               }
        }
 
-       public TypeSerializer<?>[] getTypeSerializersIn(ClassLoader cl) {
-               int typeSerializersCount = 
config.getInteger(TYPE_SERIALIZERS_IN_COUNT, -1);
-               checkState(
-                       typeSerializersCount >= 0,
-                       "Missing value for %s in the config? [%d]",
-                       TYPE_SERIALIZERS_IN_COUNT,
-                       typeSerializersCount);
-               TypeSerializer<?>[] typeSerializers = new 
TypeSerializer<?>[typeSerializersCount];
-               for (int i = 0; i < typeSerializers.length; i++) {
-                       typeSerializers[i] = getTypeSerializerIn(i, cl);
+       public void setTypeSerializersIn(TypeSerializer<?> ...serializers) {
+               Input[] inputs = new Input[serializers.length];
+               for (int i = 0; i < serializers.length; i++) {
+                       inputs[i] = new NetworkInput(serializers[i], i);
                }
-               return typeSerializers;
+               setInputs(inputs);
        }
 
-       public <T> TypeSerializer<T> getTypeSerializerIn(int index, ClassLoader 
cl) {
+       public void setInputs(Input ...inputs) {
                try {
-                       return InstantiationUtil.readObjectFromConfig(
-                               this.config,
-                               String.format(TYPE_SERIALIZERS_IN_PATTERN, 
index),
-                               cl);
-               } catch (Exception e) {
-                       throw new StreamTaskException(
-                               String.format("Could not instantiate serializer 
for [%d] input.", index),
-                               e);
+                       InstantiationUtil.writeObjectToConfig(inputs, 
this.config, INPUTS);
+               } catch (IOException e) {
+                       throw new StreamTaskException("Could not serialize 
inputs.", e);
                }
        }
 
-       public <T> TypeSerializer<T> getTypeSerializerOut(ClassLoader cl) {
+       public Input[] getInputs(ClassLoader cl) {
                try {
-                       return 
InstantiationUtil.readObjectFromConfig(this.config, TYPE_SERIALIZER_OUT_1, cl);
+                       Input[] inputs = 
InstantiationUtil.readObjectFromConfig(this.config, INPUTS, cl);
+                       if (inputs == null) {
+                               return new Input[0];
+                       }
+                       return inputs;
                } catch (Exception e) {
-                       throw new StreamTaskException("Could not instantiate 
serializer.", e);
+                       throw new StreamTaskException("Could not deserialize 
inputs", e);
                }
        }
 
-       public <T> TypeSerializer<T> getTypeSerializerSideOut(OutputTag<?> 
outputTag, ClassLoader cl) {
-               Preconditions.checkNotNull(outputTag, "Side output id must not 
be null.");
-               try {
-                       return 
InstantiationUtil.readObjectFromConfig(this.config, 
TYPE_SERIALIZER_SIDEOUT_PREFIX + outputTag.getId(), cl);
-               } catch (Exception e) {
-                       throw new StreamTaskException("Could not instantiate 
serializer.", e);
-               }
+       @Deprecated
+       public <T> TypeSerializer<T> getTypeSerializerIn1(ClassLoader cl) {
+               return getTypeSerializerIn(0, cl);
        }
 
-       private void setTypeSerializer(String key, TypeSerializer<?> 
typeWrapper) {
-               try {
-                       InstantiationUtil.writeObjectToConfig(typeWrapper, 
this.config, key);
-               } catch (IOException e) {
-                       throw new StreamTaskException("Could not serialize type 
serializer.", e);
+       @Deprecated
+       public <T> TypeSerializer<T> getTypeSerializerIn2(ClassLoader cl) {
+               return getTypeSerializerIn(1, cl);
+       }
+
+       public <T> TypeSerializer<T> getTypeSerializerIn(int index, ClassLoader 
cl) {
+               Input[] inputs = getInputs(cl);
+               if (index >= inputs.length) {
+                       return null;

Review comment:
       It was for backwards compatibility, as this is the equivalent of the 
code on the master. I think at least some of the tests are failing, that are 
manually constructing `StreamConfig`, but I'm not sure - I don't know this code 
very well. I will try to track those failures down and if are easy to fix, will 
replace it with a `checkState` 




----------------------------------------------------------------
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]


Reply via email to