Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/main/java/com/cloudera/hadoop/HadoopFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public HadoopFile(String file, Configuration configuration) {
this.configuration = configuration;
}

public void inspect() throws IOException {
public String inspect() throws IOException {
FileSystem fileSystem = FileSystem.get(configuration);
Path filePath = new Path(file);
FSDataInputStream is = fileSystem.open(filePath);
Expand All @@ -46,12 +46,11 @@ public void inspect() throws IOException {
for (Detector detector : REGISTERED_DETECTORS) {
if (detector.detect(header, read)) {
PathData pd = new PathData(file, configuration);
System.out.println(file + ": " + detector.analyze(pd, ""));
return;
return(file + ": " + detector.analyze(pd, ""));
}
}

System.out.println(file + ": octet-stream");
return (file + ": octet-stream");
}
finally {
is.close();
Expand All @@ -61,7 +60,7 @@ public void inspect() throws IOException {

@Override
public int run(String[] strings) throws Exception {
inspect();
System.out.println(inspect());
return 0;
}

Expand All @@ -75,4 +74,4 @@ public static void main(String[] args) throws Exception {
hadoopFile.run(args);
}

}
}
10 changes: 5 additions & 5 deletions src/test/java/com/cloudera/hadoop/HadoopFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ public void testTextFile() {
@Test
public void testParquetFile() throws IOException {
HadoopFile hadoopFile = new HadoopFile("src/test/resources/testparq.parq", configuration);
hadoopFile.inspect();
String result = hadoopFile.inspect();
}

@Test
public void testAvroFile() throws IOException {
HadoopFile hadoopFile = new HadoopFile("src/test/resources/testavro.avro", configuration);
hadoopFile.inspect();
String result = hadoopFile.inspect();
}

@Test
public void testSeqFile() throws IOException {
HadoopFile hadoopFile = new HadoopFile("src/test/resources/testseq.seq", configuration);
hadoopFile.inspect();
String result = hadoopFile.inspect();
}

@Test
public void testRCFile() throws IOException {
HadoopFile hadoopFile = new HadoopFile("src/test/resources/testrcfile.rcf", configuration);
hadoopFile.inspect();
String result = hadoopFile.inspect();
}

@Test
public void testORCFile() throws IOException {
HadoopFile hadoopFile = new HadoopFile("src/test/resources/testorc.orc", configuration);
hadoopFile.inspect();
String result = hadoopFile.inspect();
}

}