Skip to content

Commit

Permalink
fix how Filesystem is initialized. It should be based on both path an…
Browse files Browse the repository at this point in the history
…d conf.
  • Loading branch information
Raghu Angadi committed Sep 11, 2012
1 parent 8dd1811 commit 236f0da
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
Expand Up @@ -8,7 +8,6 @@
import com.twitter.elephantbird.util.W3CLogParser;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.MapWritable;
Expand Down Expand Up @@ -58,8 +57,8 @@ protected void createInputReader(InputStream input, Configuration conf) throws I
in_ = new LineReader(input, conf);

String fileURI = getFieldDefinitionFile();
FileSystem fs = FileSystem.get(URI.create(fileURI), conf);
InputStream is = fs.open(new Path(fileURI));
Path path = new Path(fileURI);
InputStream is = path.getFileSystem(conf).open(path);
w3cLogParser_ = new W3CLogParser(is);
is.close();
}
Expand Down
Expand Up @@ -5,7 +5,6 @@
import com.google.common.base.Preconditions;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.DataInputBuffer;
Expand Down Expand Up @@ -44,7 +43,7 @@ public void initialize(InputSplit inputSplit, TaskAttemptContext context) throws
FileSplit fileSplit = (FileSplit) inputSplit;
Path path = fileSplit.getPath();
// inhibit class loading during SequenceFile.Reader initialization
reader = new SequenceFile.Reader(FileSystem.get(conf), path, conf) {
reader = new SequenceFile.Reader(path.getFileSystem(conf), path, conf) {
@Override
public synchronized Class<?> getKeyClass() {
return BytesWritable.class;
Expand Down
Expand Up @@ -22,7 +22,7 @@
* use the following code:
* <code>
* Configuration conf = new Configuration();
* FileSystem fs = FileSystem.get(conf);
* FileSystem fs = lzoPath.getFileSystem(conf);
* FSDataOutputStream outputStream = fs.create(lzoPath, true);
* LzopCodec codec = new LzopCodec();
* codec.setConf(conf);
Expand Down
Expand Up @@ -76,7 +76,7 @@ public void setUp() throws Exception {
tempFilename = tempFile.getAbsolutePath();
Path path = new Path("file:///" + tempFilename);
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(path.toUri(), conf);
FileSystem fs = path.getFileSystem(conf);
IntWritable key = new IntWritable();
Text value = new Text();
SequenceFile.Writer writer = null;
Expand Down
Expand Up @@ -107,7 +107,7 @@ public void setup() throws IOException {
tempFilename = tempFile.getAbsolutePath();
final Path path = new Path("file:///" + tempFilename);
final Configuration conf = new Configuration();
final FileSystem fs = FileSystem.get(path.toUri(), conf);
final FileSystem fs = path.getFileSystem(conf);
final IntWritable key = new IntWritable();
SequenceFile.Writer writer = null;
try {
Expand Down

0 comments on commit 236f0da

Please sign in to comment.