[ 
https://issues.apache.org/jira/browse/FLINK-2077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14706317#comment-14706317
 ] 

ASF GitHub Bot commented on FLINK-2077:
---------------------------------------

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

    https://github.com/apache/flink/pull/1035#discussion_r37610286
  
    --- Diff: flink-core/src/main/java/org/apache/flink/core/fs/Path.java ---
    @@ -430,40 +296,127 @@ public int depth() {
        }
     
        /**
    -    * Returns a qualified path object.
    -    * 
    -    * @param fs
    -    *        the FileSystem that should be used to obtain the current 
working directory
    -    * @return the qualified path object
    +    * Checks if the provided path string is either null or has zero length 
and throws
    +    * a {@link IllegalArgumentException} if any of the two conditions 
apply.
    +    * In addition, leading and tailing whitespaces are removed.
    +    *
    +    * @param path
    +    *        the path string to be checked
    +    * @return The checked and trimmed path.
    +    */
    +   private String checkAndTrimPathArg(String path) {
    +           // disallow construction of a Path from an empty string
    +           if (path == null) {
    +                   throw new IllegalArgumentException("Can not create a 
Path from a null string");
    +           }
    +           path = path.trim();
    +           if (path.length() == 0) {
    +                   throw new IllegalArgumentException("Can not create a 
Path from an empty string");
    +           }
    +           return path;
    +   }
    +
    +   /**
    +    * Initializes a path object given the scheme, authority and path 
string.
    +    *
    +    * @param scheme
    +    *        the scheme string.
    +    * @param authority
    +    *        the authority string.
    +    * @param path
    +    *        the path string.
         */
    -   public Path makeQualified(FileSystem fs) {
    -           Path path = this;
    -           if (!isAbsolute()) {
    -                   path = new Path(fs.getWorkingDirectory(), this);
    +   private void initialize(String scheme, String authority, String path) {
    +           try {
    +                   this.uri = new URI(scheme, authority, 
normalizePath(path), null, null).normalize();
    +           } catch (URISyntaxException e) {
    +                   throw new IllegalArgumentException(e);
                }
    +   }
     
    -           final URI pathUri = path.toUri();
    -           final URI fsUri = fs.getUri();
    +   /**
    +    * Normalizes a path string.
    +    *
    +    * @param path
    +    *        the path string to normalize
    +    * @return the normalized path string
    +    */
    +   private String normalizePath(String path) {
     
    -           String scheme = pathUri.getScheme();
    -           String authority = pathUri.getAuthority();
    +           // remove leading and tailing whitespaces
    +           path = path.trim();
     
    -           if (scheme != null && (authority != null || 
fsUri.getAuthority() == null)) {
    -                   return path;
    +           // remove consecutive slashes & backslashes
    +           path = path.replace("\\", "/");
    +           path = path.replaceAll("/+", "/");
    --- End diff --
    
    Hi, @tillrohrmann  thanks for your review. But i haven't modified this line.


> Rework Path class and add extend support for Windows paths
> ----------------------------------------------------------
>
>                 Key: FLINK-2077
>                 URL: https://issues.apache.org/jira/browse/FLINK-2077
>             Project: Flink
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 0.9
>            Reporter: Fabian Hueske
>            Assignee: GaoLun
>            Priority: Minor
>              Labels: starter
>
> The class {{org.apache.flink.core.fs.Path}} handles paths for Flink's 
> {{FileInputFormat}} and {{FileOutputFormat}}. Over time, this class has 
> become quite hard to read and modify. 
> It would benefit from some cleaning and refactoring. Along with the 
> refactoring, support for Windows paths like {{//host/dir1/dir2}} could be 
> added.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to