adjusted SequenceFileReader to print the sequence file content in stdout

This commit is contained in:
Claudio Atzori 2019-10-11 11:11:16 +02:00
parent 3fb0f26393
commit 027176a88b
3 changed files with 25 additions and 10 deletions

1
MANIFEST.txt Normal file
View File

@ -0,0 +1 @@
Main-Class: com.github.sakserv.sequencefile.SequenceFileReader

21
pom.xml
View File

@ -34,6 +34,11 @@
</repositories>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@ -149,7 +154,21 @@
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.github.sakserv.sequencefile.SequenceFileReader</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>

View File

@ -16,19 +16,13 @@ package com.github.sakserv.sequencefile;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class SequenceFileReader {
// Logger
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileReader.class);
public static void main(String[] args) {
String inputFile = args[0];
@ -42,15 +36,16 @@ public class SequenceFileReader {
SequenceFile.Reader.file(seqFilePath));
Text key = new Text();
IntWritable val = new IntWritable();
Text val = new Text();
while (reader.next(key, val)) {
LOG.info("Sequence File Data: Key: " + key + "\tValue: " + val);
//LOG.info(val);
System.out.println(val);
}
reader.close();
} catch(IOException e) {
LOG.error("ERROR: Could not load hadoop configuration");
System.err.println("ERROR: Could not load hadoop configuration");
e.printStackTrace();
}