HeartSaVioR commented on a change in pull request #25911:
[SPARK-29223][SQL][SS] Enable global timestamp per topic while specifying
offset by timestamp in Kafka source
URL: https://github.com/apache/spark/pull/25911#discussion_r327462078
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaOffsetReader.scala
##########
@@ -166,83 +169,118 @@ private[kafka010] class KafkaOffsetReader(
def fetchSpecificOffsets(
partitionOffsets: Map[TopicPartition, Long],
reportDataLoss: String => Unit): KafkaSourceOffset = {
- val fnAssertParametersWithPartitions: ju.Set[TopicPartition] => Unit = {
partitions =>
- assert(partitions.asScala == partitionOffsets.keySet,
- "If startingOffsets contains specific offsets, you must specify all
TopicPartitions.\n" +
- "Use -1 for latest, -2 for earliest, if you don't care.\n" +
- s"Specified: ${partitionOffsets.keySet} Assigned:
${partitions.asScala}")
- logDebug(s"Partitions assigned to consumer: $partitions. Seeking to
$partitionOffsets")
+ val fnRetrievePartitionOffsets: (TPToOffsets, ju.Set[TopicPartition]) =>
TPToOffsets = {
+ case (newParams, _) => newParams
}
- val fnRetrievePartitionOffsets: ju.Set[TopicPartition] =>
Map[TopicPartition, Long] = { _ =>
- partitionOffsets
- }
+ fetchSpecificOffsets0(partitionOffsets,
adjustParamsWithPartitionsForOffsets,
+ fnRetrievePartitionOffsets,
assertFetchedOffsetsForOffsets(reportDataLoss))
+ }
- val fnAssertFetchedOffsets: Map[TopicPartition, Long] => Unit = { fetched
=>
- partitionOffsets.foreach {
- case (tp, off) if off != KafkaOffsetRangeLimit.LATEST &&
- off != KafkaOffsetRangeLimit.EARLIEST =>
- if (fetched(tp) != off) {
- reportDataLoss(
- s"startingOffsets for $tp was $off but consumer reset to
${fetched(tp)}")
- }
- case _ =>
- // no real way to check that beginning or end is reasonable
- }
- }
+ private def adjustParamsWithPartitionsForOffsets
Review comment:
NOTE: method values are extracted to add more code in its method definition
- it becomes too long so I didn't feel good to keep them all in a method. I
just left some of short method values as they were.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]