源码:
/** * Read per-TopicPartition offsets from json string */ def partitionOffsets(str: String): Map[TopicPartition, Long] = { try { Serialization.read[Map[String, Map[Int, Long]]](str).flatMap { case (topic, partOffsets) => partOffsets.map { case (part, offset) => new TopicPartition(topic, part) -> offset } }.toMap } catch { case NonFatal(x) => throw new IllegalArgumentException( s"""Expected e.g. {"topicA":{"0":23,"1":-1},"topicB":{"0":-2}}, got $str""") } }