Github user chandrasaripaka commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2161#discussion_r244182374
--- 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;
- } else {
- return false;
}
+ return false;
} catch (IOException e) {
LOGGER.error("Exception occured: " + e.getMessage());
return false;
+ } finally {
+ try {
+ if (null != fsdis && null != fsdos) {
+ if (fs.exists(new Path(changeToName))) {
+ fs.delete(fileStatus.getPath(), true);
--- End diff --
Reassigned the fileStatus to the changedPath
---