关注 spark技术分享,
撸spark源码 玩spark最佳实践

JsonUtils Helper Object

JsonUtils Helper Object

JsonUtils is a Scala object with methods for serializing and deserializing Kafka TopicPartitions to and from a single JSON text.

JsonUtils uses json4s library that provides a single AST with the Jackson parser for parsing to the AST (using json4s-jackson module).

Table 1. JsonUtils API
Name Description

partitionOffsets

Deserializing partition offsets (i.e. offsets per Kafka TopicPartition) from JSON, e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}

partitionOffsets

Serializing partition offsets (i.e. offsets per Kafka TopicPartition) to JSON

partitions

Deserializing TopicPartitions from JSON, e.g. {"topicA":[0,1],"topicB":[0,1]}

partitions

Serializing TopicPartitions to JSON

Deserializing Partition Offsets From JSON — partitionOffsets Method

partitionOffsets…​FIXME

Note

partitionOffsets is used when:

Serializing Partition Offsets to JSON — partitionOffsets Method

partitionOffsets…​FIXME

Note
partitionOffsets is used when…​FIXME

Serializing TopicPartitions to JSON — partitions Method

partitions…​FIXME

Note
partitions seems not to be used.

Deserializing TopicPartitions from JSON — partitions Method

partitions uses json4s-jakson’s Serialization object to read a Map[String, Seq[Int] from the input string that represents a Map of topics and partition numbers, e.g. {"topicA":[0,1],"topicB":[0,1]}.

For every pair of topic and partition number, partitions creates a new Kafka TopicPartition.

In case of any parsing issues, partitions throws a new IllegalArgumentException:

Note
partitions is used exclusively when KafkaSourceProvider is requested for a ConsumerStrategy (given assign option).
赞(0) 打赏
未经允许不得转载:spark技术分享 » JsonUtils Helper Object
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏