carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvramana <...@git.apache.org>
Subject [GitHub] carbondata pull request #1061: [CARBONDATA-1193] ViewFS Support - improvemen...
Date Fri, 07 Jul 2017 12:28:24 GMT
Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1061#discussion_r126134812
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/filesystem/AbstractDFSCarbonFile.java
---
    @@ -124,6 +128,90 @@ public boolean renameTo(String changetoName) {
         }
       }
     
    +  @Override public boolean renameForce(String changetoName) {
    +    FileSystem fs;
    +    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);
    +        return true;
    +      } else if (fs instanceof ViewFileSystem) {
    +        fs.delete(new Path(changetoName), true);
    +        fs.rename(fileStatus.getPath(), new Path(changetoName));
    +        return true;
    +      } else {
    +        return false;
    +      }
    +    } catch (IOException e) {
    +      LOGGER.error("Exception occured" + e.getMessage());
    +      return false;
    +    }
    +  }
    +
    +  public CarbonFile[] getFiles(FileStatus[] listStatus, FileFactory.FileType fileType)
{
    +    if (listStatus == null) {
    +      return new CarbonFile[0];
    +    }
    +    CarbonFile[] files = new CarbonFile[listStatus.length];
    +    if (fileType.equals(FileFactory.FileType.HDFS)) {
    +      for (int i = 0; i < files.length; i++) {
    +        files[i] = new HDFSCarbonFile(listStatus[i]);
    +      }
    +    } else if (fileType.equals(FileFactory.FileType.VIEWFS)) {
    +      for (int i = 0; i < files.length; i++) {
    +        files[i] = new ViewFSCarbonFile(listStatus[i]);
    +      }
    +    }
    +    return files;
    +  }
    +
    +  public CarbonFile[] listFiles(FileFactory.FileType fileType) {
    +    FileStatus[] listStatus = null;
    +    try {
    +      if (null != fileStatus && fileStatus.isDirectory()) {
    +        Path path = fileStatus.getPath();
    +        listStatus = path.getFileSystem(FileFactory.getConfiguration()).listStatus(path);
    +      } else {
    +        return new CarbonFile[0];
    +      }
    +    } catch (IOException ex) {
    +      LOGGER.error("Exception occured" + ex.getMessage());
    +      return new CarbonFile[0];
    +    }
    +    return getFiles(listStatus, fileType);
    +  }
    +
    +  @Override public CarbonFile[] listFiles(final CarbonFileFilter fileFilter) {
    +    CarbonFile[] files = listFiles();
    +    if (files != null && files.length >= 1) {
    +      List<CarbonFile> fileList = new ArrayList<CarbonFile>(files.length);
    +      for (int i = 0; i < files.length; i++) {
    +        if (fileFilter.accept(files[i])) {
    +          fileList.add(files[i]);
    +        }
    +      }
    +      if (fileList.size() >= 1) {
    +        return fileList.toArray(new CarbonFile[fileList.size()]);
    +      } else {
    +        return new CarbonFile[0];
    +      }
    +    }
    +    return files;
    +  }
    +
    +  public CarbonFile getParentFile(FileFactory.FileType fileType) {
    --- End diff --
    
    Have to use factory method, cannot use switchcase


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message