[
https://issues.apache.org/jira/browse/FLINK-9221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Josh Lemer updated FLINK-9221:
------------------------------
Description:
Just like it is very useful to use `DataStream[T]` as a sort of Functor or
Monad with `map`/`flatMap`/`filter` methods, it would be extremely handy to
have a `SinkFunction[A]#contramap[B](f: B => A): SinkFunction[B]` on
`SinkFunctions`, so that you can reuse existing complex sink functions, but
with a different input type. For example:
{code}
val bucketingStringSink: SinkFunction[String] =
new BucketingSink[String]("...")
.setBucketer(new DateTimeBucketer("yyyy-MM-dd-HHmm")
val bucketingIntListSink: SinkFunction[List[Int]] =
bucketingStringSink.contramap[List[Int]](_.mkString(","))
{code}
For some more formal motivation behind this,
https://typelevel.org/cats/typeclasses/contravariant.html is definitely a great
place to start!
was:
Just like it is very useful to use `DataStream[T]` as a sort of Functor or
Monad with `map`/`flatMap`/`filter` methods, it would be extremely handy to
have a `SinkFunction[A]#contramap[B](f: B => A): SinkFunction[B]` on
`SinkFunctions`, so that you can reuse existing complex sink functions, but
with a different input type. For example:
{code}
val bucketingStringSink: SinkFunction[String] =
new BucketingSink[String]("...")
.setBucketr(new DateTimeBucketer("yyyy-MM-dd-HHmm")
val bucketingIntListSink: SinkFunction[List[Int]] =
bucketingStringSink.contramap[List[Int]](_.mkString(","))
{code}
For some more formal motivation behind this,
https://typelevel.org/cats/typeclasses/contravariant.html is definitely a great
place to start!
> Add method SinkFunction[A]#contramap[B](f: B => A): SinkFunction[B]
> -------------------------------------------------------------------
>
> Key: FLINK-9221
> URL: https://issues.apache.org/jira/browse/FLINK-9221
> Project: Flink
> Issue Type: Task
> Reporter: Josh Lemer
> Priority: Minor
>
> Just like it is very useful to use `DataStream[T]` as a sort of Functor or
> Monad with `map`/`flatMap`/`filter` methods, it would be extremely handy to
> have a `SinkFunction[A]#contramap[B](f: B => A): SinkFunction[B]` on
> `SinkFunctions`, so that you can reuse existing complex sink functions, but
> with a different input type. For example:
> {code}
> val bucketingStringSink: SinkFunction[String] =
> new BucketingSink[String]("...")
> .setBucketer(new DateTimeBucketer("yyyy-MM-dd-HHmm")
> val bucketingIntListSink: SinkFunction[List[Int]] =
> bucketingStringSink.contramap[List[Int]](_.mkString(","))
> {code}
> For some more formal motivation behind this,
> https://typelevel.org/cats/typeclasses/contravariant.html is definitely a
> great place to start!
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)