Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/6397#discussion_r31006414
--- Diff:
core/src/main/scala/org/apache/spark/util/collection/ExternalSorter.scala ---
@@ -123,43 +130,28 @@ private[spark] class ExternalSorter[K, V, C](
// grow internal data structures by growing + copying every time the
number of objects doubles.
private val serializerBatchSize =
conf.getLong("spark.shuffle.spill.batchSize", 10000)
- private def getPartition(key: K): Int = {
- if (shouldPartition) partitioner.get.getPartition(key) else 0
- }
-
- private val metaInitialRecords = 256
- private val kvChunkSize = conf.getInt("spark.shuffle.sort.kvChunkSize",
1 << 22) // 4 MB
- private val useSerializedPairBuffer =
- !ordering.isDefined &&
conf.getBoolean("spark.shuffle.sort.serializeMapOutputs", true) &&
- ser.supportsRelocationOfSerializedObjects
-
// Data structures to store in-memory objects before we spill. Depending
on whether we have an
// Aggregator set, we either put objects into an AppendOnlyMap where we
combine them, or we
// store them in an array buffer.
- private var map = new PartitionedAppendOnlyMap[K, C]
- private var buffer = if (useSerializedPairBuffer) {
- new PartitionedSerializedPairBuffer[K, C](metaInitialRecords,
kvChunkSize, serInstance)
- } else {
- new PartitionedPairBuffer[K, C]
+ private def newBuffer: () => WritablePartitionedPairCollection[K, C]
with SizeTracker = {
--- End diff --
Ah, I got a bit too clever here. My idea was to reduce the visibility of
variables like `useSerializedPairBuffer` without having to recompute them on
each call to `newBuffer(0)`, so I had this block of code effectively return a
factory for creating buffers based on a configuration which is read once.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]