From 25db67c75d254edc50345507f060817b6978ac7e Mon Sep 17 00:00:00 2001 From: Grebennikov Roman Date: Thu, 23 Sep 2021 12:20:59 +0200 Subject: [PATCH 1/2] migrate to softwaremill magnolia fork --- build.sbt | 16 ++++++++-------- project/build.properties | 2 +- .../flinkadt/api/LowPrioImplicits.scala | 2 +- .../io/findify/flinkadt/api/package.scala | 4 ++-- .../api/serializer/CoproductSerializer.scala | 2 +- .../api/typeinfo/ProductTypeInformation.scala | 2 +- .../io/findify/flinkadt/SerializerTest.scala | 18 ++++++++++++++++++ 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 6eab8c2..f1c3d15 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "flink-adt" version := "0.4.3" -scalaVersion := "2.12.14" +scalaVersion := "2.12.15" organization := "io.findify" licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")) @@ -12,15 +12,15 @@ publishMavenStyle := true publishTo := sonatypePublishToBundle.value -lazy val flinkVersion = "1.13.1" +lazy val flinkVersion = "1.13.2" libraryDependencies ++= Seq( - "com.propensive" %% "magnolia" % "0.17.0", - "org.apache.flink" %% "flink-scala" % flinkVersion % "provided", - "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided", - "org.apache.flink" %% "flink-test-utils" % flinkVersion % "test", - "org.scalatest" %% "scalatest" % "3.2.9" % "test", - "org.typelevel" %% "cats-core" % "2.3.0" % "test" + "com.softwaremill.magnolia1_2" % "magnolia_2.12" % "1.0.0-M5", + "org.apache.flink" %% "flink-scala" % flinkVersion % "provided", + "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided", + "org.apache.flink" %% "flink-test-utils" % flinkVersion % "test", + "org.scalatest" %% "scalatest" % "3.2.10" % "test", + "org.typelevel" %% "cats-core" % "2.6.1" % "test" ) scmInfo := Some( diff --git a/project/build.properties b/project/build.properties index 83be3cf..215ddd2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.5.2 \ No newline at end of file +sbt.version = 1.5.5 \ No newline at end of file diff --git a/src/main/scala/io/findify/flinkadt/api/LowPrioImplicits.scala b/src/main/scala/io/findify/flinkadt/api/LowPrioImplicits.scala index 7e1ae83..5cb2a4a 100644 --- a/src/main/scala/io/findify/flinkadt/api/LowPrioImplicits.scala +++ b/src/main/scala/io/findify/flinkadt/api/LowPrioImplicits.scala @@ -1,6 +1,6 @@ package io.findify.flinkadt.api -import magnolia.Magnolia +import magnolia1.Magnolia import org.apache.flink.api.common.typeinfo.TypeInformation import scala.language.experimental.macros diff --git a/src/main/scala/io/findify/flinkadt/api/package.scala b/src/main/scala/io/findify/flinkadt/api/package.scala index 0c25f4c..93115a1 100644 --- a/src/main/scala/io/findify/flinkadt/api/package.scala +++ b/src/main/scala/io/findify/flinkadt/api/package.scala @@ -2,7 +2,7 @@ package io.findify.flinkadt import io.findify.flinkadt.api.serializer._ import io.findify.flinkadt.api.typeinfo.{CollectionTypeInformation, CoproductTypeInformation, ProductTypeInformation} -import magnolia.{CaseClass, Magnolia, SealedTrait} +import magnolia1.{CaseClass, Magnolia, SealedTrait} import org.apache.flink.api.common.ExecutionConfig import org.apache.flink.api.common.typeinfo.{BasicTypeInfo, TypeInformation} import org.apache.flink.api.common.typeutils.TypeSerializer @@ -89,7 +89,7 @@ package object api extends LowPrioImplicits { } } - private def typeName(tn: magnolia.TypeName): String = { + private def typeName(tn: magnolia1.TypeName): String = { s"${tn.full}[${tn.typeArguments.map(typeName).mkString(",")}]" } diff --git a/src/main/scala/io/findify/flinkadt/api/serializer/CoproductSerializer.scala b/src/main/scala/io/findify/flinkadt/api/serializer/CoproductSerializer.scala index 3c42b30..d56c693 100644 --- a/src/main/scala/io/findify/flinkadt/api/serializer/CoproductSerializer.scala +++ b/src/main/scala/io/findify/flinkadt/api/serializer/CoproductSerializer.scala @@ -4,7 +4,7 @@ import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, import java.util import io.findify.flinkadt.api.serializer.CoproductSerializer.CoproductSerializerSnapshot -import magnolia.{SealedTrait, Subtype, TypeName} +import magnolia1.{SealedTrait, Subtype, TypeName} import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton import org.apache.flink.api.common.typeutils.{ GenericTypeSerializerSnapshot, diff --git a/src/main/scala/io/findify/flinkadt/api/typeinfo/ProductTypeInformation.scala b/src/main/scala/io/findify/flinkadt/api/typeinfo/ProductTypeInformation.scala index 8a28056..a8417d0 100644 --- a/src/main/scala/io/findify/flinkadt/api/typeinfo/ProductTypeInformation.scala +++ b/src/main/scala/io/findify/flinkadt/api/typeinfo/ProductTypeInformation.scala @@ -1,6 +1,6 @@ package io.findify.flinkadt.api.typeinfo -import magnolia.{CaseClass, Param} +import magnolia1.{CaseClass, Param} import org.apache.flink.api.common.ExecutionConfig import org.apache.flink.api.common.typeinfo.TypeInformation import org.apache.flink.api.common.typeutils.TypeSerializer diff --git a/src/test/scala/io/findify/flinkadt/SerializerTest.scala b/src/test/scala/io/findify/flinkadt/SerializerTest.scala index d3d4255..7ece70d 100644 --- a/src/test/scala/io/findify/flinkadt/SerializerTest.scala +++ b/src/test/scala/io/findify/flinkadt/SerializerTest.scala @@ -1,6 +1,8 @@ package io.findify.flinkadt +import cats.data.NonEmptyList import io.findify.flinkadt.SerializerTest.DeeplyNested.ModeNested.SuperNested.{Egg, Food} +import io.findify.flinkadt.SerializerTest.NestedRoot.NestedMiddle.NestedBottom import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectOutputStream} import io.findify.flinkadt.SerializerTest.{ @@ -162,6 +164,16 @@ class SerializerTest extends AnyFlatSpec with Matchers with Inspectors with Test all(ser2, Generic(Simple(0, "asd"), Bar(0))) } + it should "serialize nil" in { + val ser = implicitly[TypeInformation[NonEmptyList[String]]].createSerializer(null) + roundtrip(ser, NonEmptyList.one("a")) + } + + it should "serialize triple-nested case clases" in { + val ser = implicitly[TypeInformation[Seq[NestedBottom]]].createSerializer(null) + roundtrip(ser, List(NestedBottom(Some("a"), None))) + } + } object SerializerTest { @@ -218,4 +230,10 @@ object SerializerTest { case class Generic[T](a: T, b: ADT) case class ListADT(a: List[ADT]) + + object NestedRoot { + object NestedMiddle { + case class NestedBottom(a: Option[String], b: Option[String]) + } + } } From 11726668d90d24d24e234ad2fec0a683b24581e3 Mon Sep 17 00:00:00 2001 From: Grebennikov Roman Date: Thu, 23 Sep 2021 12:21:43 +0200 Subject: [PATCH 2/2] bump to 0.4.4 --- README.md | 2 +- build.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4dd3dac..11cf1a8 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ versions `flink-adt` is released to Maven-central. For SBT, add this snippet to `build.sbt`: ```scala -libraryDependencies += "io.findify" %% "flink-adt" % "0.4.3" +libraryDependencies += "io.findify" %% "flink-adt" % "0.4.4" ``` To use this library, swap `import org.apache.flink.api.scala._` with `import io.findify.flinkadt.api._` and enjoy. diff --git a/build.sbt b/build.sbt index f1c3d15..9070ce2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := "flink-adt" -version := "0.4.3" +version := "0.4.4" scalaVersion := "2.12.15"