@Override public int read(byte[] b, int off, int length) throws IOException { if (current == null) { return -1; } if (current.remaining() == 0) { advance(); if (current == null) { return -1; } } return current.read(b, off, length); }
public long getCheckpoint() { // if the decompressed buffer is empty, return a checkpoint starting at the next block if (current == null || (current.position() == 0 && current.remaining() == 0)) { return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0); } // otherwise return a checkpoint at the last compressed block read and the current position in the buffer return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(current.position())); }
public boolean seekToCheckpoint(long checkpoint) throws IOException { int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint); int decompressedOffset = decodeDecompressedOffset(checkpoint); boolean discardedBuffer; if (compressedBlockOffset != currentCompressedBlockOffset) { if (!decompressor.isPresent()) { throw new OrcCorruptionException(orcDataSourceId, "Reset stream has a compressed block offset but stream is not compressed"); } compressedSliceInput.setPosition(compressedBlockOffset); current = EMPTY_SLICE.getInput(); discardedBuffer = true; } else { discardedBuffer = false; } if (decompressedOffset != current.position()) { current.setPosition(0); if (current.remaining() < decompressedOffset) { decompressedOffset -= current.remaining(); advance(); } current.setPosition(decompressedOffset); } return discardedBuffer; }
private void advance() throws IOException if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) { current = null; return; if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) { throw new OrcCorruptionException(orcDataSourceId, "The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining());
@Override public int read(byte[] b, int off, int length) throws IOException { if (current == null) { return -1; } if (current.remaining() == 0) { advance(); if (current == null) { return -1; } } return current.read(b, off, length); }
@Override public int read(byte[] b, int off, int length) throws IOException { if (current == null) { return -1; } if (current.remaining() == 0) { advance(); if (current == null) { return -1; } } return current.read(b, off, length); }
@Override public int read(byte[] b, int off, int length) throws IOException { if (current == null) { return -1; } if (current.remaining() == 0) { advance(); if (current == null) { return -1; } } return current.read(b, off, length); }
@Override public int read(byte[] b, int off, int length) throws IOException { if (current == null) { return -1; } if (current.remaining() == 0) { advance(); if (current == null) { return -1; } } return current.read(b, off, length); }
public long getCheckpoint() { // if the decompressed buffer is empty, return a checkpoint starting at the next block if (current == null || (current.position() == 0 && current.remaining() == 0)) { return createInputStreamCheckpoint(Ints.checkedCast(compressedSliceInput.position()), 0); } // otherwise return a checkpoint at the last compressed block read and the current position in the buffer return createInputStreamCheckpoint(currentCompressedBlockOffset, Ints.checkedCast(current.position())); }
public long getCheckpoint() { // if the decompressed buffer is empty, return a checkpoint starting at the next block if (current == null || (current.position() == 0 && current.remaining() == 0)) { return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0); } // otherwise return a checkpoint at the last compressed block read and the current position in the buffer return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(current.position())); }
public long getCheckpoint() { // if the decompressed buffer is empty, return a checkpoint starting at the next block if (current == null || (current.position() == 0 && current.remaining() == 0)) { return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0); } // otherwise return a checkpoint at the last compressed block read and the current position in the buffer return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(current.position())); }
public long getCheckpoint() { // if the decompressed buffer is empty, return a checkpoint starting at the next block if (current == null || (current.position() == 0 && current.remaining() == 0)) { return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0); } // otherwise return a checkpoint at the last compressed block read and the current position in the buffer return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(current.position())); }
public boolean seekToCheckpoint(long checkpoint) throws IOException { int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint); int decompressedOffset = decodeDecompressedOffset(checkpoint); boolean discardedBuffer; if (compressedBlockOffset != currentCompressedBlockOffset) { if (!decompressor.isPresent()) { throw new OrcCorruptionException(orcDataSourceId, "Reset stream has a compressed block offset but stream is not compressed"); } compressedSliceInput.setPosition(compressedBlockOffset); current = EMPTY_SLICE.getInput(); discardedBuffer = true; } else { discardedBuffer = false; } if (decompressedOffset != current.position()) { current.setPosition(0); if (current.remaining() < decompressedOffset) { decompressedOffset -= current.remaining(); advance(); } current.setPosition(decompressedOffset); } return discardedBuffer; }
public boolean seekToCheckpoint(long checkpoint) throws IOException { int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint); int decompressedOffset = decodeDecompressedOffset(checkpoint); boolean discardedBuffer; if (compressedBlockOffset != currentCompressedBlockOffset) { if (!decompressor.isPresent()) { throw new OrcCorruptionException(orcDataSourceId, "Reset stream has a compressed block offset but stream is not compressed"); } compressedSliceInput.setPosition(compressedBlockOffset); current = EMPTY_SLICE.getInput(); discardedBuffer = true; } else { discardedBuffer = false; } if (decompressedOffset != current.position()) { current.setPosition(0); if (current.remaining() < decompressedOffset) { decompressedOffset -= current.remaining(); advance(); } current.setPosition(decompressedOffset); } return discardedBuffer; }
public boolean seekToCheckpoint(long checkpoint) throws IOException { int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint); int decompressedOffset = decodeDecompressedOffset(checkpoint); boolean discardedBuffer; if (compressedBlockOffset != currentCompressedBlockOffset) { if (!decompressor.isPresent()) { throw new OrcCorruptionException(orcDataSourceId, "Reset stream has a compressed block offset but stream is not compressed"); } compressedSliceInput.setPosition(compressedBlockOffset); current = EMPTY_SLICE.getInput(); discardedBuffer = true; } else { discardedBuffer = false; } if (decompressedOffset != current.position()) { current.setPosition(0); if (current.remaining() < decompressedOffset) { decompressedOffset -= current.remaining(); advance(); } current.setPosition(decompressedOffset); } return discardedBuffer; }
private void advance() throws IOException if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) { current = null; return; if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) { throw new OrcCorruptionException(orcDataSourceId, "The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining());
private void advance() throws IOException if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) { current = null; return; if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) { throw new OrcCorruptionException(orcDataSourceId, "The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining());
private void advance() throws IOException if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) { current = null; return; if (chunkLength < 0 || chunkLength > compressedSliceInput.remaining()) { throw new OrcCorruptionException(orcDataSourceId, "The chunkLength (%s) must not be negative or greater than remaining size (%s)", chunkLength, compressedSliceInput.remaining());
public boolean seekToCheckpoint(long checkpoint) throws IOException { int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint); int decompressedOffset = decodeDecompressedOffset(checkpoint); boolean discardedBuffer; if (compressedBlockOffset != currentCompressedBlockOffset) { if (compressionKind == UNCOMPRESSED) { throw new OrcCorruptionException("Reset stream has a compressed block offset but stream is not compressed"); } compressedSliceInput.setPosition(compressedBlockOffset); current = EMPTY_SLICE.getInput(); discardedBuffer = true; } else { discardedBuffer = false; } if (decompressedOffset != current.position()) { current.setPosition(0); if (current.remaining() < decompressedOffset) { decompressedOffset -= current.remaining(); advance(); } current.setPosition(decompressedOffset); } return discardedBuffer; }
private void advance() throws IOException { if (compressedSliceInput == null || compressedSliceInput.remaining() == 0) { current = null; return; } // 3 byte header // NOTE: this must match BLOCK_HEADER_SIZE currentCompressedBlockOffset = Ints.checkedCast(compressedSliceInput.position()); int b0 = compressedSliceInput.readUnsignedByte(); int b1 = compressedSliceInput.readUnsignedByte(); int b2 = compressedSliceInput.readUnsignedByte(); boolean isUncompressed = (b0 & 0x01) == 1; int chunkLength = (b2 << 15) | (b1 << 7) | (b0 >>> 1); Slice chunk = compressedSliceInput.readSlice(chunkLength); if (isUncompressed) { current = chunk.getInput(); } else { int uncompressedSize; if (compressionKind == ZLIB) { uncompressedSize = decompressZip(chunk); } else { uncompressedSize = decompressSnappy(chunk); } current = Slices.wrappedBuffer(buffer, 0, uncompressedSize).getInput(); } }