Github user jackylk commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2161#discussion_r244004960 --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AlluxioCarbonFile.java --- @@ -90,21 +97,82 @@ public CarbonFile getParentFile() { return null == parent ? null : new AlluxioCarbonFile(parent); } + /** + * <p>RenameForce of the fileName for the AlluxioFileSystem Implementation. + * Involves by opening a {@link FSDataInputStream} from the existing path and copy + * bytes to {@link FSDataOutputStream}. + * </p> + * <p>Close the output and input streams only after the files have been written + * Also check for the existence of the changed path and then delete the previous Path. + * The No of Bytes that can be read is controlled by {@literal io.file.buffer.size}, + * where the default value is 4096.</p> + * @param changeToName + * @return + */ @Override public boolean renameForce(String changeToName) { - FileSystem fs; + FileSystem fs = null; + FSDataOutputStream fsdos = null; + FSDataInputStream fsdis = null; try { - fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration()); - if (fs instanceof DistributedFileSystem) { - ((DistributedFileSystem) fs).rename(fileStatus.getPath(), new Path(changeToName), - org.apache.hadoop.fs.Options.Rename.OVERWRITE); + Path actualPath = fileStatus.getPath(); + Path changedPath = new Path(changeToName); + fs = actualPath.getFileSystem(hadoopConf); + fsdos = fs.create(changedPath, true); + fsdis = fs.open(actualPath); + if (null != fsdis && null != fsdos) { + IOUtils.copyBytes(fsdis, fsdos, hadoopConf, true); return true; --- End diff -- I think what you do in the finally block should move to here and fileStatus should be assigned to point to the newly created file.
---