writer = SequenceFile.createWriter(fs, conf, sequenceName, Text.class, BytesWritable.class, CompressionType.RECORD);
String lowerName = archive.toString().toLowerCase();
if(lowerName.endsWith(".tar.gz") || lowerName.endsWith(".tgz"))
{
archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream("tar", new GZIPInputStream(new FileInputStream(archive)));
}
else if(lowerName.endsWith(".tar.bz") || lowerName.endsWith(".tar.bz2") || lowerName.endsWith(".tbz"))
{
FileInputStream is = new FileInputStream(archive);
is.read(); // read 'B'
is.read(); // read 'Z'
archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream("tar", new CBZip2InputStream(is));
}
else if(lowerName.endsWith(".tar"))
{
archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream("tar", new FileInputStream(archive));
}
else if(lowerName.endsWith(".zip"))
{
archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream("zip", new FileInputStream(archive));
}
else
{
throw new RuntimeException("Can't handle archive format for: "+archive);
}