use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class OrcInputStream method readFully.
public void readFully(Slice buffer, int inputOffset, int inputLength) throws IOException {
int offset = inputOffset;
int length = inputLength;
while (length > 0) {
if (current != null && current.remaining() == 0) {
advance();
}
if (current == null) {
throw new OrcCorruptionException(chunkLoader.getOrcDataSourceId(), "Unexpected end of stream");
}
int chunkSize = min(length, (int) current.remaining());
current.readBytes(buffer, offset, chunkSize);
length -= chunkSize;
offset += chunkSize;
}
}
use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class UncompressedOrcChunkLoader method seekToCheckpoint.
@Override
public void seekToCheckpoint(long checkpoint) throws OrcCorruptionException {
int compressedOffset = decodeCompressedBlockOffset(checkpoint);
if (compressedOffset != 0) {
throw new OrcCorruptionException(dataReader.getOrcDataSourceId(), "Uncompressed stream does not support seeking to a compressed offset");
}
int decompressedOffset = decodeDecompressedOffset(checkpoint);
nextPosition = decompressedOffset;
lastCheckpoint = checkpoint;
}
use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class DecimalColumnReader method readBlock.
@Override
public Block readBlock() throws IOException {
if (!rowGroupOpen) {
openRowGroup();
}
seekToOffset();
Block block;
if (decimalStream == null && scaleStream == null) {
if (presentStream == null) {
throw new OrcCorruptionException(column.getOrcDataSourceId(), "Value is null but present stream is missing");
}
presentStream.skip(nextBatchSize);
block = RunLengthEncodedBlock.create(type, null, nextBatchSize);
} else if (presentStream == null) {
checkDataStreamsArePresent();
block = readNonNullBlock();
} else {
checkDataStreamsArePresent();
boolean[] isNull = new boolean[nextBatchSize];
int nullCount = presentStream.getUnsetBits(nextBatchSize, isNull);
if (nullCount == 0) {
block = readNonNullBlock();
} else if (nullCount != nextBatchSize) {
block = readNullBlock(isNull, nextBatchSize - nullCount);
} else {
block = RunLengthEncodedBlock.create(DOUBLE, null, nextBatchSize);
}
}
readOffset = 0;
nextBatchSize = 0;
return block;
}
use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class DoubleColumnReader method readBlock.
@Override
public Block readBlock() throws IOException {
if (!rowGroupOpen) {
openRowGroup();
}
if (readOffset > 0) {
if (presentStream != null) {
// skip ahead the present bit reader, but count the set bits
// and use this as the skip size for the data reader
readOffset = presentStream.countBitsSet(readOffset);
}
if (readOffset > 0) {
if (dataStream == null) {
throw new OrcCorruptionException(column.getOrcDataSourceId(), "Value is not null but data stream is missing");
}
dataStream.skip(readOffset);
}
}
Block block;
if (dataStream == null) {
if (presentStream == null) {
throw new OrcCorruptionException(column.getOrcDataSourceId(), "Value is null but present stream is missing");
}
presentStream.skip(nextBatchSize);
block = RunLengthEncodedBlock.create(DOUBLE, null, nextBatchSize);
} else if (presentStream == null) {
block = readNonNullBlock();
} else {
boolean[] isNull = new boolean[nextBatchSize];
int nullCount = presentStream.getUnsetBits(nextBatchSize, isNull);
if (nullCount == 0) {
block = readNonNullBlock();
} else if (nullCount != nextBatchSize) {
block = readNullBlock(isNull, nextBatchSize - nullCount);
} else {
block = RunLengthEncodedBlock.create(DOUBLE, null, nextBatchSize);
}
}
readOffset = 0;
nextBatchSize = 0;
return block;
}
use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class FloatColumnReader method readBlock.
@Override
public Block readBlock() throws IOException {
if (!rowGroupOpen) {
openRowGroup();
}
if (readOffset > 0) {
if (presentStream != null) {
// skip ahead the present bit reader, but count the set bits
// and use this as the skip size for the data reader
readOffset = presentStream.countBitsSet(readOffset);
}
if (readOffset > 0) {
if (dataStream == null) {
throw new OrcCorruptionException(column.getOrcDataSourceId(), "Value is not null but data stream is missing");
}
dataStream.skip(readOffset);
}
}
Block block;
if (dataStream == null) {
if (presentStream == null) {
throw new OrcCorruptionException(column.getOrcDataSourceId(), "Value is null but present stream is missing");
}
presentStream.skip(nextBatchSize);
block = RunLengthEncodedBlock.create(REAL, null, nextBatchSize);
} else if (presentStream == null) {
block = readNonNullBlock();
} else {
boolean[] isNull = new boolean[nextBatchSize];
int nullCount = presentStream.getUnsetBits(nextBatchSize, isNull);
if (nullCount == 0) {
block = readNonNullBlock();
} else if (nullCount != nextBatchSize) {
block = readNullBlock(isNull, nextBatchSize - nullCount);
} else {
block = RunLengthEncodedBlock.create(REAL, null, nextBatchSize);
}
}
readOffset = 0;
nextBatchSize = 0;
return block;
}
Aggregations