@Override protected InputStream createInputStream(InputStream parent) throws IOException { return new SnappyInputStream(parent); }
protected static SnappyInputStream getDelegate( InputStream in ) throws IOException { SnappyInputStream delegate = null; if ( in instanceof SnappyInputStream ) { delegate = (SnappyInputStream) in; } else { delegate = new SnappyInputStream( in ); } return delegate; }
@Override InputStream getInputStream(final InputStream source) throws IOException { return new SnappyInputStream(source); } }
private void decompress(InputStream input, OutputStream output) throws IOException { byte data[] = new byte[BUFFER]; try (BufferedOutputStream dest1 = new BufferedOutputStream(output, BUFFER); SnappyInputStream is = new SnappyInputStream(new BufferedInputStream(input))) { int c; while ((c = is.read(data, 0, BUFFER)) != -1) { dest1.write(data, 0, c); } } } }
try { in = new BufferedInputStream(new FileInputStream(compressed)); snappyIn = new SnappyInputStream(in); out = new FileOutputStream(decompressed);
private SnappyInputStream createSnappyInputStream() throws IOException { // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions) ByteArrayOutputStream baos = new ByteArrayOutputStream(); SnappyOutputStream sos = new SnappyOutputStream( baos ); byte[] testBytes = "Test".getBytes(); sos.write( testBytes ); ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() ); sos.close(); return new SnappyInputStream( in ); } }
private SnappyInputStream createSnappyInputStream() throws IOException { // Create an in-memory ZIP output stream for use by the input stream (to avoid exceptions) ByteArrayOutputStream baos = new ByteArrayOutputStream(); SnappyOutputStream sos = new SnappyOutputStream( baos ); byte[] testBytes = "Test".getBytes(); sos.write( testBytes ); ByteArrayInputStream in = new ByteArrayInputStream( baos.toByteArray() ); sos.close(); return new SnappyInputStream( in ); } }
break; case COMPRESSION_FORMAT_SNAPPY: compressionIn = new SnappyInputStream(bufferedIn); break; case COMPRESSION_FORMAT_SNAPPY_FRAMED:
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (final SnappyInputStream sis = new SnappyInputStream(new ByteArrayInputStream(flowFile.toByteArray())); final OutputStream out = baos) { final byte[] buffer = new byte[8192]; int len; while ((len = sis.read(buffer)) > 0) {
@Override public InputStream decompress(InputStream input) throws IOException { return new SnappyInputStream(input); } };
@Override protected InputStream getBlockDecompressionInputStream(InputStream inputStream) throws IOException { return new SnappyInputStream(inputStream); } }
@Override InputStream getInputStream(final InputStream source) throws IOException { return new SnappyInputStream(source); } }
private DataInputStream createBlockFileInput(File file) throws IOException { if (compress) { return new DataInputStream(new SnappyInputStream(new FileInputStream(file))); } else { return new DataInputStream(new BufferedInputStream(new FileInputStream(file), INPUT_BUFFER_SIZE)); } }
public static InputStream toInputStream(com.google.protobuf.ByteString json, FragmentCodec codec) throws IOException { final FragmentCodec c = codec != null ? codec : FragmentCodec.NONE; final InputStream input = json.newInput(); switch(c) { case NONE: return input; case SNAPPY: return new SnappyInputStream(input); default: throw new UnsupportedOperationException("Do not know how to uncompress using " + c + " algorithm."); } }
@NotNull @Override public InputStream decompressingStream(InputStream input) throws IORuntimeException { try { return new SnappyInputStream(input); } catch (IOException e) { throw new IORuntimeException(e); } }
private static InputStream getCompressInputStream(FSDataInputStream fdis, Path path) throws IOException { String name = path.getName(); if(name.toLowerCase().endsWith(".gz")) { return new GZIPInputStream(fdis); } else if(name.toLowerCase().endsWith(".bz2")) { return new BZip2CompressorInputStream(fdis); } else if(name.toLowerCase().endsWith(".snappy")) { return new SnappyInputStream(fdis); } else { return fdis; } }
public static void decompressFileSnappy(File src, File dst) throws IOException { if (!dst.getParentFile().exists()) dst.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(dst); FileInputStream fis = new FileInputStream(src); SnappyInputStream is = new SnappyInputStream(fis); IOUtils.copy(is, fos); fos.flush(); fos.close(); fis.close(); }
@Override public Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo) throws IOException { InputStream inputStream = new ByteBufInputStream(byteBuf); inputStream = new SnappyInputStream(inputStream); if (rpcMethodInfo instanceof ProtobufRpcMethodInfo) { return ((ProtobufRpcMethodInfo) rpcMethodInfo).inputDecode(inputStream); } else { byte[] uncompressedBytes = IOUtils.readInputStream(inputStream); return rpcMethodInfo.inputDecode(uncompressedBytes); } }
@Override public Object uncompressInput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo) throws IOException { InputStream inputStream = new DynamicCompositeByteBufInputStream(byteBuf); inputStream = new SnappyInputStream(inputStream); if (rpcMethodInfo instanceof ProtobufRpcMethodInfo) { return ((ProtobufRpcMethodInfo) rpcMethodInfo).inputDecode(inputStream); } else { byte[] uncompressedBytes = IOUtils.readInputStream(inputStream); return rpcMethodInfo.inputDecode(uncompressedBytes); } }
@Override public Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo) throws IOException { InputStream inputStream = new ByteBufInputStream(byteBuf); inputStream = new SnappyInputStream(inputStream); if (rpcMethodInfo instanceof ProtobufRpcMethodInfo) { return ((ProtobufRpcMethodInfo) rpcMethodInfo).inputDecode(inputStream); } else { byte[] uncompressedBytes = IOUtils.readInputStream(inputStream); return rpcMethodInfo.inputDecode(uncompressedBytes); } }