Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22404#discussion_r217153478
  
    --- Diff: 
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/SimpleDownloadFile.java
 ---
    @@ -0,0 +1,89 @@
    +/*
    + * 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.network.shuffle;
    +
    +import org.apache.spark.network.buffer.FileSegmentManagedBuffer;
    +import org.apache.spark.network.buffer.ManagedBuffer;
    +import org.apache.spark.network.util.TransportConf;
    +
    +import java.io.*;
    +import java.nio.ByteBuffer;
    +import java.nio.channels.Channels;
    +import java.nio.channels.WritableByteChannel;
    +
    +/**
    + * A DownloadFile that does not take any encryption settings into account 
for reading and
    + * writing data.
    + *
    + * This does *not* mean the data in the file is un-encrypted -- it could 
be that the data is
    + * already encrypted when its written, and subsequent layer is responsible 
for decrypting.
    + */
    +public class SimpleDownloadFile implements DownloadFile {
    +  private final File file;
    +  private final TransportConf transportConf;
    +
    +  public SimpleDownloadFile(File file, TransportConf transportConf) {
    +    this.file = file;
    +    this.transportConf = transportConf;
    +  }
    +
    +  @Override
    +  public boolean delete() {
    +    return file.delete();
    +  }
    +
    +  @Override
    +  public DownloadFileWritableChannel openForWriting() {
    +    try {
    +      return new SimpleDownloadWritableChannel();
    +    } catch (FileNotFoundException e) {
    +      throw new RuntimeException(e);
    +    }
    +  }
    +
    +  @Override
    +  public String path() {
    +    return file.getAbsolutePath();
    +  }
    +
    +  private class SimpleDownloadWritableChannel implements 
DownloadFileWritableChannel {
    +    private final WritableByteChannel channel;
    --- End diff --
    
    More nits, would put blank lines around this


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to