public HadoopSnappyOutputStream(OutputStream out, int bufferSize) { super(out); inputBuffer = new byte[bufferSize]; // leave extra space free at end of buffers to make compression (slightly) faster inputMaxSize = inputBuffer.length - compressionOverhead(bufferSize); outputBuffer = new byte[compressor.maxCompressedLength(inputMaxSize) + SIZE_OF_LONG]; }
public HadoopSnappyOutputStream(OutputStream out, int bufferSize) { super(out); inputBuffer = new byte[bufferSize]; // leave extra space free at end of buffers to make compression (slightly) faster inputMaxSize = inputBuffer.length - compressionOverhead(bufferSize); outputBuffer = new byte[compressor.maxCompressedLength(inputMaxSize) + SIZE_OF_LONG]; }
public SnappyFramedOutputStream(OutputStream out, boolean writeChecksums, int blockSize, double minCompressionRatio) throws IOException { this.out = SnappyInternalUtils.checkNotNull(out, "out is null"); this.writeChecksums = writeChecksums; SnappyInternalUtils.checkArgument(minCompressionRatio > 0 && minCompressionRatio <= 1.0, "minCompressionRatio %1s must be between (0,1.0].", minCompressionRatio); this.minCompressionRatio = minCompressionRatio; this.blockSize = blockSize; this.buffer = new byte[blockSize]; this.outputBuffer = new byte[compressor.maxCompressedLength(blockSize)]; out.write(SnappyFramed.HEADER_BYTES); SnappyInternalUtils.checkArgument(blockSize > 0 && blockSize <= MAX_BLOCK_SIZE, "blockSize must be in (0, 65536]", blockSize); }
public SnappyFramedOutputStream(OutputStream out, boolean writeChecksums, int blockSize, double minCompressionRatio) throws IOException { this.out = SnappyInternalUtils.checkNotNull(out, "out is null"); this.writeChecksums = writeChecksums; SnappyInternalUtils.checkArgument(minCompressionRatio > 0 && minCompressionRatio <= 1.0, "minCompressionRatio %1s must be between (0,1.0].", minCompressionRatio); this.minCompressionRatio = minCompressionRatio; this.blockSize = blockSize; this.buffer = new byte[blockSize]; this.outputBuffer = new byte[compressor.maxCompressedLength(blockSize)]; out.write(SnappyFramed.HEADER_BYTES); SnappyInternalUtils.checkArgument(blockSize > 0 && blockSize <= MAX_BLOCK_SIZE, "blockSize must be in (0, 65536]", blockSize); }
@Override public int maxCompressedLength(int uncompressedSize) { return new SnappyCompressor().maxCompressedLength(uncompressedSize); }
@Override public int maxCompressedLength(int uncompressedSize) { return new SnappyCompressor().maxCompressedLength(uncompressedSize); }
public static byte[] blockCompress(byte[] data) { SnappyCompressor compressor = new SnappyCompressor(); byte[] compressedOut = new byte[compressor.maxCompressedLength(data.length)]; int compressedSize = compressor.compress(data, 0, data.length, compressedOut, 0, compressedOut.length); byte[] trimmedBuffer = Arrays.copyOf(compressedOut, compressedSize); return trimmedBuffer; }