Skip to content

Commit

Permalink
fixup! fixup! Add HadoopResourceId
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Sisk committed Apr 25, 2017
1 parent 4dd919a commit c1e6cbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import java.net.URI;
import org.apache.beam.sdk.io.fs.ResolveOptions;
import org.apache.beam.sdk.io.fs.ResourceId;
import org.apache.hadoop.fs.Path;
Expand All @@ -29,7 +30,7 @@
*/
public class HadoopResourceId implements ResourceId {

private final Path path;
private final URI uri;

/**
* Constructs a HadoopResourceId from the provided absolute path. If only a relative path is
Expand All @@ -43,7 +44,7 @@ public static HadoopResourceId fromPath(Path path) {
}

private HadoopResourceId(Path path) {
this.path = path;
this.uri = path.toUri();
}

@Override
Expand All @@ -59,7 +60,7 @@ public ResourceId resolve(String other, ResolveOptions resolveOptions) {
"ResolveOptions: [%s] ends with '/', which is not supported for RESOLVE_FILE.",
other);
}
return new HadoopResourceId(new Path(path, other));
return new HadoopResourceId(new Path(new Path(uri), other));
}

@Override
Expand All @@ -71,15 +72,15 @@ public ResourceId getCurrentDirectory() {

@Override
public String getScheme() {
return path.toUri().getScheme();
return uri.getScheme();
}

public Path getPath() {
return path;
return new Path(uri);
}

@Override
public String toString() {
return path.toString();
return uri.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.sdk.io.hdfs;

import static org.junit.Assert.assertEquals;
Expand Down

0 comments on commit c1e6cbc

Please sign in to comment.