MCPcopy Create free account
hub / github.com/apache/pig / readOutput

Method readOutput

test/org/apache/pig/test/Util.java:393–424  ·  view source on GitHub ↗
(FileSystem fs, String fileName)

Source from the content-addressed store, hash-verified

391 }
392
393 static public String[] readOutput(FileSystem fs, String fileName) throws IOException {
394 if(Util.WINDOWS){
395 fileName = fileName.replace('\\','/');
396 }
397 Path path = new Path(fileName);
398 if(!fs.exists(path)) {
399 throw new IOException("Path " + fileName + " does not exist on the FileSystem");
400 }
401 FileStatus fileStatus = fs.getFileStatus(path);
402 FileStatus[] files;
403 if (fileStatus.isDir()) {
404 files = fs.listStatus(path, new PathFilter() {
405 @Override
406 public boolean accept(Path p) {
407 return !p.getName().startsWith("_");
408 }
409 });
410 } else {
411 files = new FileStatus[] { fileStatus };
412 }
413 List<String> result = new ArrayList<String>();
414 for (FileStatus f : files) {
415 FSDataInputStream stream = fs.open(f.getPath());
416 BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
417 String line;
418 while ((line = br.readLine()) != null) {
419 result.add(line);
420 }
421 br.close();
422 }
423 return result.toArray(new String[result.size()]);
424 }
425
426 /**
427 * Helper to create a dfs file on the MiniCluster dfs. This returns an

Callers 4

varargTestMethod · 0.95
firstTestMethod · 0.95

Calls 13

toConfigurationMethod · 0.95
toArrayMethod · 0.80
replaceMethod · 0.65
existsMethod · 0.65
openMethod · 0.65
addMethod · 0.65
closeMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
listStatusMethod · 0.45
getPathMethod · 0.45
readLineMethod · 0.45

Tested by

no test coverage detected