flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljoscha <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-2203] handling null values for RowSeria...
Date Sat, 13 Jun 2015 11:27:22 GMT
Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/831#discussion_r32369781
  
    --- Diff: flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/typeinfo/RowSerializer.scala
---
    @@ -74,11 +79,16 @@ class RowSerializer(fieldSerializers: Array[TypeSerializer[Any]])
     
       override def serialize(value: Row, target: DataOutputView) {
         val len = fieldSerializers.length
    -    var i = 0
    -    while (i < len) {
    -      val serializer = fieldSerializers(i)
    -      serializer.serialize(value.productElement(i), target)
    -      i += 1
    +    (0 to len - 1).foreach {
    +      index =>
    +        val o: AnyRef = value.productElement(index).asInstanceOf[AnyRef]
    +        if (o == null) {
    +          target.writeBoolean(true)
    +        } else {
    +          target.writeBoolean(false)
    +          val serializer = fieldSerializers(index)
    +          serializer.serialize(value.productElement(index), target)
    +        }
    --- End diff --
    
    Could you please change this back to the simple while loop. I know that using the fancy
Scala features is tempting but the performance of a simple while loop should be better than
creating a range and iterating over it using foreach.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message