zhengruifeng commented on code in PR #38612:
URL: https://github.com/apache/spark/pull/38612#discussion_r1019843494
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/arrow/ArrowConverters.scala:
##########
@@ -161,17 +166,23 @@ private[sql] object ArrowConverters extends Logging {
val writeChannel = new WriteChannel(Channels.newChannel(out))
var rowCount = 0L
+ var estimatedBatchSize = arrowSchemaSize
Utils.tryWithSafeFinally {
- while (rowIter.hasNext && (maxRecordsPerBatch <= 0 || rowCount <
maxRecordsPerBatch)) {
+ // Always write the schema.
+ MessageSerializer.serialize(writeChannel, arrowSchema)
+
+ // Always write the first row.
+ while (rowIter.hasNext && (rowCount == 0 || estimatedBatchSize <
maxBatchSize)) {
val row = rowIter.next()
arrowWriter.write(row)
+ estimatedBatchSize += row.asInstanceOf[UnsafeRow].getSizeInBytes
Review Comment:
will update `maxBatchSize * 0.7`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]