use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class ShortColumnReader method readBlock.
@Override
public Block<Short> 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(SmallintType.SMALLINT, 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(SmallintType.SMALLINT, null, nextBatchSize);
}
}
readOffset = 0;
nextBatchSize = 0;
return block;
}
use of io.prestosql.orc.OrcCorruptionException in project hetu-core by openlookeng.
the class OrcDeletedRows method isDeleted.
private boolean isDeleted(OrcAcidRowId sourcePageRowId) {
if (sortedRowsIterator == null) {
for (WriteIdInfo deleteDeltaInfo : deleteDeltaLocations.getDeleteDeltas()) {
Path path = createPath(deleteDeltaLocations.getPartitionLocation(), deleteDeltaInfo, sourceFileName);
try {
FileSystem fileSystem = hdfsEnvironment.getFileSystem(sessionUser, path, configuration);
FileStatus fileStatus = hdfsEnvironment.doAs(sessionUser, () -> fileSystem.getFileStatus(path));
pageSources.add(pageSourceFactory.createPageSource(fileStatus.getPath(), fileStatus.getLen(), fileStatus.getModificationTime()));
} catch (FileNotFoundException ignored) {
// source file does not have a delta delete file in this location
continue;
} catch (PrestoException e) {
throw e;
} catch (OrcCorruptionException e) {
throw new PrestoException(HiveErrorCode.HIVE_BAD_DATA, format("Failed to read ORC file: %s", path), e);
} catch (RuntimeException | IOException e) {
throw new PrestoException(HiveErrorCode.HIVE_CURSOR_ERROR, format("Failed to read ORC file: %s", path), e);
}
}
List<Type> columnTypes = ImmutableList.of(BigintType.BIGINT, IntegerType.INTEGER, BigintType.BIGINT);
// Last index for rowIdHandle
List<Integer> sortFields = ImmutableList.of(0, 1, 2);
List<SortOrder> sortOrders = ImmutableList.of(SortOrder.ASC_NULLS_FIRST, SortOrder.ASC_NULLS_FIRST, SortOrder.ASC_NULLS_FIRST);
sortedRowsIterator = HiveUtil.getMergeSortedPages(pageSources, columnTypes, sortFields, sortOrders);
}
do {
if (currentPage == null || currentPageOffset >= currentPage.getPositionCount()) {
currentPage = null;
currentPageOffset = 0;
if (sortedRowsIterator.hasNext()) {
currentPage = sortedRowsIterator.next();
} else {
// No more entries in deleted_delta
return false;
}
}
do {
deletedRowId.set(currentPage, currentPageOffset);
if (deletedRowId.compareTo(sourcePageRowId) == 0) {
// source row is deleted.
return true;
} else if (deletedRowId.compareTo(sourcePageRowId) > 0) {
// So current source row is not deleted.
return false;
}
currentPageOffset++;
} while (currentPageOffset < currentPage.getPositionCount());
} while (sortedRowsIterator.hasNext());
// No more entries;
return false;
}
Aggregations