use of com.baidu.hugegraph.loader.source.file.Compression in project incubator-hugegraph-toolchain by apache.
the class FileLineFetcher method createCompressReader.
private static Reader createCompressReader(InputStream stream, FileSource source) throws Exception {
Compression compression = source.compression();
String charset = source.charset();
switch(compression) {
case NONE:
return new InputStreamReader(stream, charset);
case SNAPPY_RAW:
Configuration config = new Configuration();
CompressionCodec codec = ReflectionUtils.newInstance(SnappyCodec.class, config);
CompressionInputStream sis = codec.createInputStream(stream, codec.createDecompressor());
return new InputStreamReader(sis, charset);
case GZIP:
case BZ2:
case XZ:
case LZMA:
case SNAPPY_FRAMED:
case Z:
case DEFLATE:
case LZ4_BLOCK:
case LZ4_FRAMED:
CompressorStreamFactory factory = new CompressorStreamFactory();
CompressorInputStream cis = factory.createCompressorInputStream(compression.string(), stream);
return new InputStreamReader(cis, charset);
default:
throw new LoadException("Unsupported compression format '%s'", compression);
}
}
Aggregations