parthchandra commented on code in PR #5392: URL: https://github.com/apache/datafusion-comet/pull/5392#discussion_r3817551860
########## spark/src/test/scala/org/apache/spark/sql/comet/execution/shuffle/CometNativeShuffleInputRDDSuite.scala: ########## @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.spark.sql.comet.execution.shuffle + +import org.apache.spark.serializer.JavaSerializer +import org.apache.spark.sql.CometTestBase + +/** + * Ensure that serialized RDD does not overflow in size with a very large number of partitions + * Lives in the `execution.shuffle` package so it can construct the `private[shuffle]` + * [[CometNativeShuffleInputRDD]] directly. + */ +class CometNativeShuffleInputRDDSuite extends CometTestBase { + + test("serialized RDD size is independent of partition count") { + val sc = spark.sparkContext + val ser = new JavaSerializer(sc.getConf).newInstance() + + // One scan key with a 1KB blob per map partition. Pre-fix the whole array serializes into the + // RDD, so 10000 partitions add ~10MB versus 10. + def buildRDD(numPartitions: Int): CometNativeShuffleInputRDD = { + val perPartitionByKey = + Map("scan-0" -> Array.fill(numPartitions)(new Array[Byte](1024))) + new CometNativeShuffleInputRDD( + sc, + inputRDDs = Seq.empty, + numPartitionsParam = numPartitions, + shuffleScanIndices = Set.empty, + perPartitionByKey = perPartitionByKey) + } + + val smallSize = ser.serialize(buildRDD(10)).limit() + val large = buildRDD(10000) + val largeSize = ser.serialize(large).limit() Review Comment: Good suggestion; added ! This will now fail if someone removes the `@transient` on `NativeExecContext.perPartitionByKey`. -- 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]
