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

Tatum Alenko commented on BEAM-7247:
------------------------------------

Ditto here, this is a major pain point for using Kotlin + Beam. I'd be totally 
willing to give it a crack too if someone could give me some pointers on the 
strategy and feasibility of a solution for this. 

Currently, to make use of custom sealed class hierarchy collections, I have to 
use {{java.lang.Iterable}} and annotate the sealed super class type 
({{CsvRow}}) with {{@JvmWildcard}}:

 

{{class DecodeCsvStringToCsvRow : DoFn<String, JavaIterable<@JvmWildcard 
CsvRow>>() {}}
{{ private val logger by Logging.logger \{ }}}
{{   @ProcessElement}}
{{   fun processElement(@Element element: String, receiver: 
OutputReceiver<JavaIterable<@JvmWildcard CsvRow>>) {}}
{{      val decoded = Csv().decodeFromString<CsvRow>(element)}}
{{      logger.info(decoded.toString())}}
{{      receiver.output(decoded as JavaIterable<@kotlin.jvm.JvmWildcard 
CsvRow>)}}
{{   }}}
{{}}}

{{...}}

{{input}}
{{   .apply(ParDo.of(new DecodeCsvStringToCsvRow()))}}
{{   .setCoder(IterableCoder.of(SerializableCoder.of(CsvRow.class)))}}


 Casting Kotlin collections to {{java.lang.Iterable}} becomes really inelegant, 
let alone the use of {{@JvmStatic}}.

 

> DoFnSignatures analysis of @ProcessElement with @Element fails when Java SDK 
> is used from Kotlin
> ------------------------------------------------------------------------------------------------
>
>                 Key: BEAM-7247
>                 URL: https://issues.apache.org/jira/browse/BEAM-7247
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Kenneth Knowles
>            Priority: P3
>              Labels: Clarified
>
> https://stackoverflow.com/questions/55908999/kotlin-iterable-not-supported-in-apache-beam/55911859#55911859
> https://gist.github.com/marcoslin/e1e19afdbacac9757f6974592cfd8d7f#file-stack-trace-txt



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

Reply via email to