flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Ewen <se...@apache.org>
Subject Re: Compilation error with Scala case class with private constructor
Date Thu, 03 Mar 2016 20:14:59 GMT
Hi!

My guess is that this error is indirectly reporting that no TypeInformation
could be generated for the case class. That TypeInformation is generated
using macros during program compilation.

The generated TypeInformation will contain a partially code-generated
serializer including the code to instantiate the case class upon
deserialization. That generated code at some point calls the constructor
and thus probably fails to compile when the constructor is private. As a
result, no TypeInformation will be created, and then Scala cannot provide
one for the implicit parameter.

I think Aljoscha can probably give a deeper insight into the
TypeInformation generator for Scala.

Is it a problem for your use case to make the constructor public?

Greetings,
Stephan


On Thu, Mar 3, 2016 at 9:06 PM, Andrew Whitaker <
andrew.whitaker@braintreepayments.com> wrote:

> Hi,
>
> I've run up against a compilation error involving a case class with a
> private constructor:
>
> [error]
> /Users/anwhitaker/code/flink-fold-issue/src/main/scala/TestApp.scala:18:
> could not find implicit value for evidence parameter of type
> org.apache.flink.api.common.typeinfo.TypeInformation[List[scala.util.Try[TestApp.Wrapper]]]
> [error]       .fold(List[Try[Wrapper]](), new FoldFunction[Tuple2[Int,
> Int], List[Try[Wrapper]]] {
> [error]            ^
> [error] one error found
> [error] (compile:compileIncremental) Compilation failed
>
> If I make the constructor public again, the error goes away. I've set up a
> simple example that demonstrates the problem here:
> https://github.com/AndrewWhitaker/flink-case-class-private-ctor
> I've read this article on Flink's website:
> https://flink.apache.org/faq.html#why-am-i-getting-a-nonserializableexception-
> but I think my issue is slightly different.
>
> I'm just trying to understand this behavior and if there's a way I can
> work around it.
>
> Thanks!
>
> --
> Andrew Whitaker | andrew.whitaker@braintreepayments.com
>

Mime
View raw message