You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2017/05/02 14:12:45 UTC

[21/50] [abbrv] incubator-carbondata git commit: Remove fs, it may not be initialized when create a instance using AbstractDFSCarbonFile(FileStatus fileStatus). Fixed spelling mistakes

Remove fs, it may not be initialized when create a instance using AbstractDFSCarbonFile(FileStatus fileStatus).
Fixed spelling mistakes


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/8a1cd7dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/8a1cd7dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/8a1cd7dd

Branch: refs/heads/12-dev
Commit: 8a1cd7dd6896e96755b2acb7086a75075b66b9b5
Parents: e2e21e3
Author: smallyard <li...@live.cn>
Authored: Thu Apr 27 10:31:58 2017 +0800
Committer: smallyard <li...@live.cn>
Committed: Thu Apr 27 10:31:58 2017 +0800

----------------------------------------------------------------------
 .../filesystem/AbstractDFSCarbonFile.java       | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8a1cd7dd/core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java b/core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java
index eaff6e8..8a86d92 100644
--- a/core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java
+++ b/core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java
@@ -38,25 +38,26 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
   private static final LogService LOGGER =
       LogServiceFactory.getLogService(AbstractDFSCarbonFile.class.getName());
   protected FileStatus fileStatus;
-  protected FileSystem fs;
 
   public AbstractDFSCarbonFile(String filePath) {
     filePath = filePath.replace("\\", "/");
     Path path = new Path(filePath);
+    FileSystem fs;
     try {
       fs = path.getFileSystem(FileFactory.getConfiguration());
       fileStatus = fs.getFileStatus(path);
     } catch (IOException e) {
-      LOGGER.error("Exception occured:" + e.getMessage());
+      LOGGER.error("Exception occurred:" + e.getMessage());
     }
   }
 
   public AbstractDFSCarbonFile(Path path) {
+    FileSystem fs;
     try {
       fs = path.getFileSystem(FileFactory.getConfiguration());
       fileStatus = fs.getFileStatus(path);
     } catch (IOException e) {
-      LOGGER.error("Exception occured:" + e.getMessage());
+      LOGGER.error("Exception occurred:" + e.getMessage());
     }
   }
 
@@ -66,7 +67,9 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
 
   @Override public boolean createNewFile() {
     Path path = fileStatus.getPath();
+    FileSystem fs;
     try {
+      fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration());
       return fs.createNewFile(path);
     } catch (IOException e) {
       return false;
@@ -86,13 +89,14 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
   }
 
   @Override public boolean exists() {
+    FileSystem fs;
     try {
       if (null != fileStatus) {
         fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration());
         return fs.exists(fileStatus.getPath());
       }
     } catch (IOException e) {
-      LOGGER.error("Exception occured:" + e.getMessage());
+      LOGGER.error("Exception occurred:" + e.getMessage());
     }
     return false;
   }
@@ -115,7 +119,7 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
       fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration());
       return fs.rename(fileStatus.getPath(), new Path(changetoName));
     } catch (IOException e) {
-      LOGGER.error("Exception occured:" + e.getMessage());
+      LOGGER.error("Exception occurred:" + e.getMessage());
       return false;
     }
   }
@@ -126,7 +130,7 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
       fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration());
       return fs.delete(fileStatus.getPath(), true);
     } catch (IOException e) {
-      LOGGER.error("Exception occured:" + e.getMessage());
+      LOGGER.error("Exception occurred:" + e.getMessage());
       return false;
     }
   }
@@ -136,7 +140,9 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
   }
 
   @Override public boolean setLastModifiedTime(long timestamp) {
+    FileSystem fs;
     try {
+      fs = fileStatus.getPath().getFileSystem(FileFactory.getConfiguration());
       fs.setTimes(fileStatus.getPath(), timestamp, timestamp);
     } catch (IOException e) {
       return false;
@@ -159,7 +165,7 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
     String tempWriteFilePath = fileName + CarbonCommonConstants.TEMPWRITEFILEEXTENSION;
     FileFactory.FileType fileType = FileFactory.getFileType(fileName);
     try {
-      CarbonFile tempFile = null;
+      CarbonFile tempFile;
       // delete temporary file if it already exists at a given path
       if (FileFactory.isFileExist(tempWriteFilePath, fileType)) {
         tempFile = FileFactory.getCarbonFile(tempWriteFilePath, fileType);
@@ -191,7 +197,7 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
       tempFile.renameForce(fileName);
       fileTruncatedSuccessfully = true;
     } catch (IOException e) {
-      LOGGER.error("Exception occured while truncating the file " + e.getMessage());
+      LOGGER.error("Exception occurred while truncating the file " + e.getMessage());
     } finally {
       CarbonUtil.closeStreams(dataOutputStream, dataInputStream);
     }
@@ -203,7 +209,7 @@ public abstract  class AbstractDFSCarbonFile implements CarbonFile {
    *
    * @param fileTimeStamp time to be compared with latest timestamp of file
    * @param endOffset     file length to be compared with current length of file
-   * @return
+   * @return whether a file has been modified or not
    */
   @Override public boolean isFileModified(long fileTimeStamp, long endOffset) {
     boolean isFileModified = false;