summaryzb commented on code in PR #3767: URL: https://github.com/apache/incubator-gluten/pull/3767#discussion_r1559370666
########## gluten-uniffle/velox/src/main/java/org/apache/spark/shuffle/writer/VeloxUniffleColumnarShuffleWriter.java: ########## @@ -0,0 +1,261 @@ +/* + * 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.shuffle.writer; + +import org.apache.gluten.GlutenConfig; +import org.apache.gluten.columnarbatch.ColumnarBatches; +import org.apache.gluten.memory.memtarget.MemoryTarget; +import org.apache.gluten.memory.memtarget.Spiller; +import org.apache.gluten.memory.memtarget.Spillers; +import org.apache.gluten.memory.nmm.NativeMemoryManagers; +import org.apache.gluten.vectorized.ShuffleWriterJniWrapper; +import org.apache.gluten.vectorized.SplitResult; + +import org.apache.spark.SparkConf; +import org.apache.spark.TaskContext; +import org.apache.spark.executor.ShuffleWriteMetrics; +import org.apache.spark.memory.SparkMemoryUtil; +import org.apache.spark.scheduler.MapStatus; +import org.apache.spark.shuffle.ColumnarShuffleDependency; +import org.apache.spark.shuffle.GlutenShuffleUtils; +import org.apache.spark.shuffle.RssShuffleHandle; +import org.apache.spark.shuffle.RssShuffleManager; +import org.apache.spark.shuffle.RssSparkConfig; +import org.apache.spark.sql.vectorized.ColumnarBatch; +import org.apache.spark.util.SparkResourceUtil; +import org.apache.uniffle.client.api.ShuffleWriteClient; +import org.apache.uniffle.common.ShuffleBlockInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + +import scala.Option; +import scala.Product2; +import scala.collection.Iterator; + +public class VeloxUniffleColumnarShuffleWriter<K, V> extends RssShuffleWriter<K, V, V> { + + private static final Logger LOG = + LoggerFactory.getLogger(VeloxUniffleColumnarShuffleWriter.class); + + private long nativeShuffleWriter = -1L; + + private boolean stopping = false; + private int compressThreshold = GlutenConfig.getConf().columnarShuffleCompressionThreshold(); + private double reallocThreshold = GlutenConfig.getConf().columnarShuffleReallocThreshold(); + private String compressionCodec; + private int compressionLevel; + private int partitionId; + + private ShuffleWriterJniWrapper jniWrapper = ShuffleWriterJniWrapper.create(); + private SplitResult splitResult; + private int nativeBufferSize = GlutenConfig.getConf().maxBatchSize(); + private int bufferSize; + private PartitionPusher partitionPusher; + + private final ColumnarShuffleDependency<K, V, V> columnarDep; + private final SparkConf sparkConf; + + private long availableOffHeapPerTask() { + return SparkMemoryUtil.getCurrentAvailableOffHeapMemory() + / SparkResourceUtil.getTaskSlots(sparkConf); + } + + public VeloxUniffleColumnarShuffleWriter( + int partitionId, + String appId, + int shuffleId, + String taskId, + long taskAttemptId, + ShuffleWriteMetrics shuffleWriteMetrics, + RssShuffleManager shuffleManager, + SparkConf sparkConf, + ShuffleWriteClient shuffleWriteClient, + RssShuffleHandle<K, V, V> rssHandle, + Function<String, Boolean> taskFailureCallback, + TaskContext context) { + super( + appId, + shuffleId, + taskId, + taskAttemptId, + shuffleWriteMetrics, + shuffleManager, + sparkConf, + shuffleWriteClient, + rssHandle, + taskFailureCallback, + context); + columnarDep = (ColumnarShuffleDependency<K, V, V>) rssHandle.getDependency(); + this.partitionId = partitionId; + this.sparkConf = sparkConf; + bufferSize = + (int) + sparkConf.getSizeAsBytes( + RssSparkConfig.RSS_WRITER_BUFFER_SIZE.key(), + RssSparkConfig.RSS_WRITER_BUFFER_SIZE.defaultValue().get()); + compressionCodec = GlutenShuffleUtils.getCompressionCodec(sparkConf); Review Comment: Fix -- 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]
