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

    https://github.com/apache/spark/pull/3798#discussion_r23737948
  
    --- Diff: 
external/kafka/src/main/scala/org/apache/spark/streaming/kafka/KafkaUtils.scala 
---
    @@ -144,4 +150,116 @@ object KafkaUtils {
         createStream[K, V, U, T](
           jssc.ssc, kafkaParams.toMap, 
Map(topics.mapValues(_.intValue()).toSeq: _*), storageLevel)
       }
    +
    +  /** A batch-oriented interface for consuming from Kafka.
    +   * Starting and ending offsets are specified in advance,
    +   * so that you can control exactly-once semantics.
    +   * @param sc SparkContext object
    +   * @param kafkaParams Kafka <a 
href="http://kafka.apache.org/documentation.html#configuration";>
    +   * configuration parameters</a>.
    +   *   Requires "metadata.broker.list" or "bootstrap.servers" to be set 
with Kafka broker(s),
    +   *   NOT zookeeper servers, specified in host1:port1,host2:port2 form.
    +   * @param batch Each OffsetRange in the batch corresponds to a
    +   *   range of offsets for a given Kafka topic/partition
    +   * @param messageHandler function for translating each message into the 
desired type
    +   */
    +  def createRDD[
    +    K: ClassTag,
    +    V: ClassTag,
    +    U <: Decoder[_]: ClassTag,
    +    T <: Decoder[_]: ClassTag,
    +    R: ClassTag] (
    +      sc: SparkContext,
    +      kafkaParams: Map[String, String],
    +      batch: Array[OffsetRange],
    +      messageHandler: MessageAndMetadata[K, V] => R
    +  ): RDD[R] = {
    +    val parts = batch.zipWithIndex.map { case (o, i) =>
    +        new KafkaRDDPartition(i, o.topic, o.partition, o.fromOffset, 
o.untilOffset, o.host, o.port)
    +    }.toArray
    +    new KafkaRDD[K, V, U, T, R](sc, kafkaParams, parts, messageHandler)
    +  }
    +
    +  /**
    +   * This DOES NOT guarantee that side-effects of an action will see each 
message exactly once.
    --- End diff --
    
    If you're willing to add whatever is necessary, what I'm suggesting is 
necessary is a different method name.
    
    What's the harm in picking a more accurate method name?  
    
    Why open the possibility of someone looking at code completion in their 
IDE, seeing a method named "exactlyOnce", thinking it actually means exactly 
once, then losing money because their messages got duplicated?
    
    Many of the existing input stream classes would meet your definition of 
exactly once, but no where else in spark streaming is there a method named 
"exactlyOnce".  Why is this method special?
    
    The distinction you are drawing between receiving exactly once and 
outputting exactly once may be clear to you, but from talking with average 
users at conferences and meetups, it is not clear to them.  Judging from the 
comments on this thread and the design doc, it's not even perfectly clear to 
dedicated members of the community.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to