Github user jerryshao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8237#discussion_r37255803
  
    --- Diff: 
external/kafka/src/main/scala/org/apache/spark/streaming/kafka/KafkaRDD.scala 
---
    @@ -253,16 +253,19 @@ object KafkaRDD {
           fromOffsets: Map[TopicAndPartition, Long],
           untilOffsets: Map[TopicAndPartition, LeaderOffset],
           messageHandler: MessageAndMetadata[K, V] => R
    -    ): KafkaRDD[K, V, U, T, R] = {
    +    ): Option[KafkaRDD[K, V, U, T, R]] = {
         val leaders = untilOffsets.map { case (tp, lo) =>
             tp -> (lo.host, lo.port)
         }.toMap
     
    -    val offsetRanges = fromOffsets.map { case (tp, fo) =>
    -        val uo = untilOffsets(tp)
    -        OffsetRange(tp.topic, tp.partition, fo, uo.offset)
    -    }.toArray
    +    val offsetRanges = fromOffsets.map { case (tp, fo) => (tp, fo, 
untilOffsets(tp).offset) }
    +      .filter {case (_, fo, uo) => fo < uo }
    +      .map { case (tp, fo, uo) => OffsetRange(tp, fo, uo) }.toArray
     
    -    new KafkaRDD[K, V, U, T, R](sc, kafkaParams, offsetRanges, leaders, 
messageHandler)
    +    if (offsetRanges.isEmpty) {
    +      None
    --- End diff --
    
    As I remembered, return `None` will lead to errors for some streaming 
operations, you'd better return a empty RDD. Also I think this change cannot be 
compilable, right? Since you changed the return value of KafkaRDD, whereas you 
didn't change the related APIs in `KafkaUtils`. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to