Hi flink users,
I just wanted to ask if this kind of scala map function is correct?
object JsonMapper {
private val mapper: ObjectMapper = new ObjectMapper()
}
class JsonMapper extends MapFunction[String, ObjectNode] {
override def map(value: String): ObjectNode =
JsonMapper.mapper.readValue(value, classOf[ObjectNode])
}
Is using a static reference to ObjectMapper fine or will this cause issues on a
distributed cluster / with checkpoint / serializing state / whatever ?
Or should I instead use a non-transient property initialized in ctor
(ObjectMapper is java.io.Serializable) ?
Or should I initialize it with RichMapFunction.open into a transient property?
Also I am wondering if replacing 'class' with 'object' (=> singleton)
object JsonMapper extends MapFunction[String, ObjectNode] { /* ..*/ }
is ok (actually the mapper is stateless so no obvious need to re-instantiate it
again and again ? )
Thanks and best regards
Peter