[ 
https://issues.apache.org/jira/browse/FLINK-16724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17064753#comment-17064753
 ] 

Chongchen Chen commented on FLINK-16724:
----------------------------------------

 making history data deserialized correctly is a hard problem.  I have a 
solution, but it's tricky. Maybe we should have a better solution.
{code:java}
// code placeholder
public void serialize(List<T> list, DataOutputView target) throws IOException {
   final int size = list.size();
   target.writeInt(-size); // use negative num to represent new serialization 
schema. in deserialize method, if non-negative value is found, use old schema, 
otherwise use new schema.

   // We iterate here rather than accessing by index, because we cannot be sure 
that
   // the given list supports RandomAccess.
   // The Iterator should be stack allocated on new JVMs (due to escape 
analysis)
   for (T element : list) {
      boolean isNull = element == null;
      target.writeBoolean(isNull);
      if (!isNull) {
         elementSerializer.serialize(element, target);
      }
   }
}{code}
 

> ListSerializer cannot serialize list which containers null
> ----------------------------------------------------------
>
>                 Key: FLINK-16724
>                 URL: https://issues.apache.org/jira/browse/FLINK-16724
>             Project: Flink
>          Issue Type: Bug
>            Reporter: Chongchen Chen
>            Priority: Major
>         Attachments: list_serializer_err.diff
>
>
> MapSerializer handles null value correctly, but ListSerializer doesn't. The 
> attachment is the modification of unit test that can reproduce the bug.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to