int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
cos.write(expBytes); cos.flush();
compressingStream.write(buffer, offset, length); compressingStream.flush(); compressedStream.toByteArray();
compressedByteStream.reset(); compressionStream.resetState(); compressionStream.write(uncompressedBytesWithHeaderBuffer, headerBytes.length + uncompressedBytesWithHeaderOffset, uncompressedBytesWithHeaderLength - headerBytes.length); compressionStream.flush(); compressedByteStream.write(headerBytes); compressionStream.resetState(); compressionStream.write(uncompressedBytesWithHeaderBuffer, headerBytes.length + uncompressedBytesWithHeaderOffset, uncompressedBytesWithHeaderLength - headerBytes.length);
/** * Read data from the original input stream and pipe it to the compressing stream until fully read. */ private void streamAndCompressInput() { try { byte[] newline = "\n".getBytes(Charsets.UTF_8); while (!_closed && fetchNextRow()) { _rawOut.write(_buffer.array(), 0, _buffer.limit()); _rawOut.write(newline); } _rawOut.close(); } catch (Exception e) { try { Closer closer = Closer.create(); closer.register(_rawOut); closer.register(_gzipIn); closer.close(); } catch (IOException ignore) { // Ignore exceptions closing, don't mask the original exception. } if (!_closed) { _inputException = e instanceof IOException ? (IOException ) e : new IOException(e); } } }
/** * Read data from the original input stream and pipe it to the compressing stream until fully read. */ private void streamAndCompressInput() { try { byte[] newline = "\n".getBytes(Charsets.UTF_8); while (!_closed && fetchNextRow()) { _rawOut.write(_buffer.array(), 0, _buffer.limit()); _rawOut.write(newline); } _rawOut.close(); } catch (Exception e) { try { Closer closer = Closer.create(); closer.register(_rawOut); closer.register(_gzipIn); closer.close(); } catch (IOException ignore) { // Ignore exceptions closing, don't mask the original exception. } if (!_closed) { _inputException = e instanceof IOException ? (IOException ) e : new IOException(e); } } }
@Override public CompressionOutputStream createOutputStream(OutputStream out) throws IOException { CompressionOutputStream ret = super.createOutputStream(out); CompressionOutputStream spy = Mockito.spy(ret); Mockito.doAnswer(new GenericTestUtils.SleepAnswer(5)) .when(spy).write(Mockito.<byte[]>any(), Mockito.anyInt(), Mockito.anyInt()); return spy; } }
try { cos = codec.createOutputStream(bos, c); cos.write(b); } finally { if (cos != null) {
private void version20compression() throws IOException { onDiskChecksum = HConstants.EMPTY_BYTE_ARRAY; if (compressAlgo != NONE) { compressedByteStream.reset(); compressedByteStream.write(DUMMY_HEADER_NO_CHECKSUM); compressionStream.resetState(); compressionStream.write(uncompressedBytesWithHeader, headerSize(this.minorVersion), uncompressedBytesWithHeader.length - headerSize(this.minorVersion)); compressionStream.flush(); compressionStream.finish(); onDiskDataSizeWithHeader = compressedByteStream.size(); // data size onDiskBytesWithHeader = compressedByteStream.toByteArray(); put20Header(onDiskBytesWithHeader, 0, onDiskBytesWithHeader.length, uncompressedBytesWithHeader.length); //set the header for the uncompressed bytes (for cache-on-write) put20Header(uncompressedBytesWithHeader, 0, onDiskBytesWithHeader.length + onDiskChecksum.length, uncompressedBytesWithHeader.length); } else { onDiskBytesWithHeader = uncompressedBytesWithHeader; onDiskDataSizeWithHeader = onDiskBytesWithHeader.length; //set the header for the uncompressed bytes put20Header(uncompressedBytesWithHeader, 0, onDiskBytesWithHeader.length, uncompressedBytesWithHeader.length); } }
int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
int len = in.read(buffer); while (len > 0) { out.write(buffer, 0, len); len = in.read(buffer);
compressionStream.write(uncompressedBytesWithHeader, headerSize(this.minorVersion), uncompressedBytesWithHeader.length - headerSize(this.minorVersion));
try { cos = codec.createOutputStream(bos, c2); cos.write(b); } finally { if (cos != null) {
try { cos = codec.createOutputStream(bos, c); cos.write(b); } finally { if (cos != null) {
try { cos = codec.createOutputStream(bos, c); cos.write(b); } finally { if (cos != null) {
try { cos = codec.createOutputStream(bos, c2); cos.write(b); } finally { if (cos != null) {
try { cos = codec.createOutputStream(bos, c2); cos.write(b); } finally { if (cos != null) {