/** {@inheritDoc} */ @Override public int available() throws IOException { if (inUncompressedChunk) { return Math.min(uncompressedBytesRemaining, in.available()); } else if (currentCompressedChunk != null) { return currentCompressedChunk.available(); } return 0; }
final long before = currentCompressedChunk.getBytesRead(); read = currentCompressedChunk.read(b, off, len); if (read == -1) { currentCompressedChunk.close(); currentCompressedChunk = null; } else { count(currentCompressedChunk.getBytesRead() - before);
/** * {@inheritDoc} */ @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (endReached) { return -1; } switch (state) { case NO_BLOCK: fill(); return read(b, off, len); case IN_LITERAL: int litLen = readLiteral(b, off, len); if (!hasMoreDataInBlock()) { state = State.NO_BLOCK; } return litLen > 0 ? litLen : read(b, off, len); case IN_BACK_REFERENCE: int backReferenceLen = readBackReference(b, off, len); if (!hasMoreDataInBlock()) { state = State.NO_BLOCK; } return backReferenceLen > 0 ? backReferenceLen : read(b, off, len); default: throw new IOException("Unknown stream state " + state); } }
new SnappyCompressorInputStream(new BoundedInputStream(in, size), blockSize); count(currentCompressedChunk.getBytesRead()); } else {
/** {@inheritDoc} */ @Override public void close() throws IOException { try { if (currentCompressedChunk != null) { currentCompressedChunk.close(); currentCompressedChunk = null; } } finally { in.close(); } }
/** * @return The size of the uncompressed contents of the given compressor input stream, or -1L if unknown * @deprecated Should be replaced by a new method {@code CompressorInputStream.getUncompressedSize()} */ @Deprecated public static long getUncompressedSize(CompressorInputStream compressorInputStream) { if (compressorInputStream instanceof SnappyCompressorInputStream) { return ((SnappyCompressorInputStream) compressorInputStream).getSize(); } return -1; }
/** * {@inheritDoc} */ @Override public int read(final byte[] b, final int off, final int len) throws IOException { if (endReached) { return -1; } switch (state) { case NO_BLOCK: fill(); return read(b, off, len); case IN_LITERAL: int litLen = readLiteral(b, off, len); if (!hasMoreDataInBlock()) { state = State.NO_BLOCK; } return litLen > 0 ? litLen : read(b, off, len); case IN_BACK_REFERENCE: int backReferenceLen = readBackReference(b, off, len); if (!hasMoreDataInBlock()) { state = State.NO_BLOCK; } return backReferenceLen > 0 ? backReferenceLen : read(b, off, len); default: throw new IOException("Unknown stream state " + state); } }
new SnappyCompressorInputStream(new BoundedInputStream(in, size), blockSize); count(currentCompressedChunk.getBytesRead()); } else {
/** {@inheritDoc} */ @Override public void close() throws IOException { if (currentCompressedChunk != null) { currentCompressedChunk.close(); currentCompressedChunk = null; } in.close(); }
/** * @return The size of the uncompressed contents of the given compressor input stream, or -1L if unknown * @deprecated Should be replaced by a new method {@code CompressorInputStream.getUncompressedSize()} */ @Deprecated public static long getUncompressedSize(CompressorInputStream compressorInputStream) { if (compressorInputStream instanceof SnappyCompressorInputStream) { return ((SnappyCompressorInputStream) compressorInputStream).getSize(); } return -1; }
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new SnappyCompressorInputStream(containerInputStream); } }
final long before = currentCompressedChunk.getBytesRead(); read = currentCompressedChunk.read(b, off, len); if (read == -1) { currentCompressedChunk.close(); currentCompressedChunk = null; } else { count(currentCompressedChunk.getBytesRead() - before);
/** {@inheritDoc} */ @Override public int available() throws IOException { if (inUncompressedChunk) { return Math.min(uncompressedBytesRemaining, in.available()); } else if (currentCompressedChunk != null) { return currentCompressedChunk.available(); } return 0; }
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new SnappyCompressorInputStream(containerInputStream); } }
@Override public CompressorInputStream compressorInputStream(InputStream is) throws IOException { return new SnappyCompressorInputStream(is); }
@Override public CompressorInputStream compressorInputStream(InputStream is) throws IOException { return new SnappyCompressorInputStream(is); }
@Override public CompressorInputStream open(File compressedFile) throws IOException { InputStream is = new FileInputStream(compressedFile); try { return new SnappyCompressorInputStream(is); } catch (IOException ioe) { try { is.close(); } catch (Exception e) {} throw ioe; } }
@Override public CompressorInputStream open(File compressedFile) throws IOException { InputStream is = new FileInputStream(compressedFile); try { return new SnappyCompressorInputStream(is); } catch (IOException ioe) { try { is.close(); } catch (Exception e) {} throw ioe; } }
/** * @param stream the stream to read from, should be buffered */ @Override public CompressorInputStream getCompressorStream(InputStream stream) throws IOException { return framed ? new FramedSnappyCompressorInputStream(stream) : (CompressorInputStream) new SnappyCompressorInputStream(stream); }