You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HeartSaVioR (via GitHub)" <gi...@apache.org> on 2024/08/29 22:49:39 UTC

Re: [PR] [WIP][SPARK-49259][SS]Size based partition creation during kafka read [spark]

HeartSaVioR commented on code in PR #47927:
URL: https://github.com/apache/spark/pull/47927#discussion_r1737326651


##########
connector/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaOffsetRangeCalculator.scala:
##########
@@ -80,21 +83,39 @@ private[kafka010] class KafkaOffsetRangeCalculator(val minPartitions: Option[Int
         } else {
           getPartCount(size, splitRangeTotalSize, splitRangeMinPartitions)
         }
-        var remaining = size
-        var startOffset = range.fromOffset
-        (0 until parts).map { part =>
-          // Fine to do integer division. Last partition will consume all the round off errors
-          val thisPartition = remaining / (parts - part)
-          remaining -= thisPartition
-          val endOffset = math.min(startOffset + thisPartition, range.untilOffset)
-          val offsetRange = KafkaOffsetRange(tp, startOffset, endOffset, None)
-          startOffset = endOffset
-          offsetRange
-        }
+        getDividedPartition(parts, range)
+      }.filter(_.size > 0)
+    } else {
+      val avgMessageSize = 1 // Todo estimate row size

Review Comment:
   It is the main challenge on this approach - if you don't have an idea to calculate this in general, the overall proposal just does not work.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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