-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from findify/fix/stackoverflow-on-list
fix issue with :: stackoverflow
- Loading branch information
Showing
5 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/scala/io/findify/flinkadt/api/serializer/ListCCSerializer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.findify.flinkadt.api.serializer | ||
|
||
import org.apache.flink.api.common.typeutils.{TypeSerializer, TypeSerializerSnapshot} | ||
import org.apache.flink.core.memory.{DataInputView, DataOutputView} | ||
|
||
class ListCCSerializer[T](child: TypeSerializer[T], clazz: Class[T]) extends SimpleSerializer[::[T]] { | ||
override def createInstance(): ::[T] = throw new IllegalArgumentException("cannot create instance of non-empty list") | ||
override def getLength: Int = -1 | ||
override def deserialize(source: DataInputView): ::[T] = { | ||
val count = source.readInt() | ||
val result = for { | ||
_ <- 0 until count | ||
} yield { | ||
child.deserialize(source) | ||
} | ||
::(result.head, result.tail.toList) | ||
} | ||
override def serialize(record: ::[T], target: DataOutputView): Unit = { | ||
target.writeInt(record.size) | ||
record.foreach(element => child.serialize(element, target)) | ||
} | ||
override def snapshotConfiguration(): TypeSerializerSnapshot[::[T]] = | ||
new CollectionSerializerSnapshot(child, classOf[ListCCSerializer[T]], clazz) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters