use of com.facebook.presto.orc.OrcCorruptionException in project presto by prestodb.
the class ByteStreamReader method readBlock.
@Override
public Block readBlock(Type type) 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("Value is not null but data stream is not present");
}
dataStream.skip(readOffset);
}
}
BlockBuilder builder = type.createBlockBuilder(new BlockBuilderStatus(), nextBatchSize);
if (presentStream == null) {
if (dataStream == null) {
throw new OrcCorruptionException("Value is not null but data stream is not present");
}
dataStream.nextVector(type, nextBatchSize, builder);
} else {
if (nullVector.length < nextBatchSize) {
nullVector = new boolean[nextBatchSize];
}
int nullValues = presentStream.getUnsetBits(nextBatchSize, nullVector);
if (nullValues != nextBatchSize) {
if (dataStream == null) {
throw new OrcCorruptionException("Value is not null but data stream is not present");
}
dataStream.nextVector(type, nextBatchSize, builder, nullVector);
} else {
for (int i = 0; i < nextBatchSize; i++) {
builder.appendNull();
}
}
}
readOffset = 0;
nextBatchSize = 0;
return builder.build();
}
use of com.facebook.presto.orc.OrcCorruptionException in project presto by prestodb.
the class FloatStreamReader method readBlock.
@Override
public Block readBlock(Type type) 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("Value is not null but data stream is not present");
}
dataStream.skip(readOffset);
}
}
BlockBuilder builder = type.createBlockBuilder(new BlockBuilderStatus(), nextBatchSize);
if (presentStream == null) {
if (dataStream == null) {
throw new OrcCorruptionException("Value is not null but data stream is not present");
}
dataStream.nextVector(type, nextBatchSize, builder);
} else {
if (nullVector.length < nextBatchSize) {
nullVector = new boolean[nextBatchSize];
}
int nullValues = presentStream.getUnsetBits(nextBatchSize, nullVector);
if (nullValues != nextBatchSize) {
if (dataStream == null) {
throw new OrcCorruptionException("Value is not null but data stream is not present");
}
dataStream.nextVector(type, nextBatchSize, builder, nullVector);
} else {
for (int i = 0; i < nextBatchSize; i++) {
builder.appendNull();
}
}
}
readOffset = 0;
nextBatchSize = 0;
return builder.build();
}
use of com.facebook.presto.orc.OrcCorruptionException in project presto by prestodb.
the class LongStreamV1 method readValues.
// This comes from the Apache Hive ORC code
private void readValues() throws IOException {
lastReadInputCheckpoint = input.getCheckpoint();
int control = input.read();
if (control == -1) {
throw new OrcCorruptionException("Read past end of RLE integer from %s", input);
}
if (control < 0x80) {
numLiterals = control + MIN_REPEAT_SIZE;
used = 0;
repeat = true;
delta = input.read();
if (delta == -1) {
throw new OrcCorruptionException("End of stream in RLE Integer from %s", input);
}
// convert from 0 to 255 to -128 to 127 by converting to a signed byte
// noinspection SillyAssignment
delta = (byte) delta;
literals[0] = LongDecode.readVInt(signed, input);
} else {
numLiterals = 0x100 - control;
used = 0;
repeat = false;
for (int i = 0; i < numLiterals; ++i) {
literals[i] = LongDecode.readVInt(signed, input);
}
}
}
use of com.facebook.presto.orc.OrcCorruptionException in project presto by prestodb.
the class LongStreamV2 method readValues.
// This comes from the Apache Hive ORC code
private void readValues() throws IOException {
lastReadInputCheckpoint = input.getCheckpoint();
// read the first 2 bits and determine the encoding type
int firstByte = input.read();
if (firstByte < 0) {
throw new OrcCorruptionException("Read past end of RLE integer from %s", input);
}
int enc = (firstByte >>> 6) & 0x03;
if (EncodingType.SHORT_REPEAT.ordinal() == enc) {
readShortRepeatValues(firstByte);
} else if (EncodingType.DIRECT.ordinal() == enc) {
readDirectValues(firstByte);
} else if (EncodingType.PATCHED_BASE.ordinal() == enc) {
readPatchedBaseValues(firstByte);
} else {
readDeltaValues(firstByte);
}
}
use of com.facebook.presto.orc.OrcCorruptionException in project presto by prestodb.
the class ByteStream method readNextBlock.
// This is based on the Apache Hive ORC code
private void readNextBlock() throws IOException {
lastReadInputCheckpoint = input.getCheckpoint();
int control = input.read();
if (control == -1) {
throw new OrcCorruptionException("Read past end of buffer RLE byte from %s", input);
}
offset = 0;
// if byte high bit is not set, this is a repetition; otherwise it is a literal sequence
if ((control & 0x80) == 0) {
length = control + MIN_REPEAT_SIZE;
// read the repeated value
int value = input.read();
if (value == -1) {
throw new OrcCorruptionException("Reading RLE byte got EOF");
}
// fill buffer with the value
Arrays.fill(buffer, 0, length, (byte) value);
} else {
// length is 2's complement of byte
length = 0x100 - control;
// read the literals into the buffer
readFully(input, buffer, 0, length);
}
}
Aggregations