Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.utils.SparkArrowUtil
import org.apache.spark.sql.vectorized.ColumnarBatch
import org.apache.spark.task.TaskResources
import org.apache.spark.util.KnownSizeEstimation

import org.apache.arrow.c.ArrowSchema

Expand Down Expand Up @@ -61,7 +62,8 @@ case class ColumnarBuildSideRelation(
output: Seq[Attribute],
batches: Array[Array[Byte]],
safeBroadcastMode: SafeBroadcastMode)
extends BuildSideRelation {
extends BuildSideRelation
with KnownSizeEstimation {

// Rebuild the real BroadcastMode on demand; never serialize it.
@transient override lazy val mode: BroadcastMode =
Expand Down Expand Up @@ -236,4 +238,11 @@ case class ColumnarBuildSideRelation(
}
iterator.toArray
}
override def estimatedSize: Long = {
if (batches != null) {
batches.map(_.length.toLong).sum
} else {
0L
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.utils.SparkArrowUtil
import org.apache.spark.sql.vectorized.ColumnarBatch
import org.apache.spark.task.TaskResources
import org.apache.spark.util.Utils
import org.apache.spark.util.{KnownSizeEstimation, Utils}

import com.esotericsoftware.kryo.{Kryo, KryoSerializable}
import com.esotericsoftware.kryo.io.{Input, Output}
Expand Down Expand Up @@ -102,7 +102,8 @@ case class UnsafeColumnarBuildSideRelation(
extends BuildSideRelation
with Externalizable
with Logging
with KryoSerializable {
with KryoSerializable
with KnownSizeEstimation {

// Rebuild the real BroadcastMode on demand; never serialize it.
@transient override lazy val mode: BroadcastMode =
Expand Down Expand Up @@ -366,4 +367,12 @@ case class UnsafeColumnarBuildSideRelation(
}
iterator.toArray
}

override def estimatedSize: Long = {
if (batches != null) {
batches.totalBytes
} else {
0L
}
}
}
Loading