use of io.prestosql.spi.HetuConstant.DATASOURCE_FILE_MODIFICATION in project hetu-core by openlookeng.
the class OrcRecordReader method nextPage.
public Page nextPage() throws IOException {
ColumnReader[] columnsReader = getColumnReaders();
int batchSize = prepareNextBatch();
if (batchSize < 0) {
return null;
}
for (ColumnReader column : columnsReader) {
if (column != null) {
column.prepareNextRead(batchSize);
}
}
batchRead(batchSize);
matchingRowsInBatchArray = null;
validateWritePageChecksum(batchSize);
// create a lazy page
blockFactory.nextPage();
Arrays.fill(currentBytesPerCell, 0);
Block[] blocks = new Block[columnsReader.length];
for (int i = 0; i < columnsReader.length; i++) {
int columnIndex = i;
blocks[columnIndex] = blockFactory.createBlock(batchSize, () -> filterRows(columnsReader[columnIndex].readBlock()), block -> blockLoaded(columnIndex, block));
}
// only include page metadata if enabled
if (pageMetadataEnabled) {
Properties pageMetadata = new Properties();
pageCount++;
pageMetadata.setProperty(DATASOURCE_PAGE_NUMBER, String.valueOf(pageCount));
if (isCurrentStripeFinished()) {
// Only set the total page count when the current stripe has finished
// Therefore whenever this property is available in pageMetaData,
// it indicates that the stripe has finished and this is the last page
pageMetadata.setProperty(DATASOURCE_TOTAL_PAGES, String.valueOf(pageCount));
pageCount = 0;
}
pageMetadata.setProperty(DATASOURCE_STRIPE_NUMBER, String.valueOf(currentStripe));
pageMetadata.setProperty(DATASOURCE_STRIPE_OFFSET, String.valueOf(stripes.get(currentStripe).getOffset()));
pageMetadata.setProperty(DATASOURCE_STRIPE_LENGTH, String.valueOf(stripes.get(currentStripe).getTotalLength()));
if (splitMetadata != null) {
// Skip setting for testing (splitMetadata set as null)
pageMetadata.setProperty(DATASOURCE_FILE_PATH, splitMetadata.getSplitIdentity());
pageMetadata.setProperty(DATASOURCE_FILE_MODIFICATION, String.valueOf(splitMetadata.getLastModifiedTime()));
}
pageMetadata.setProperty(DATASOURCE_INDEX_LEVEL, "STRIPE");
return new Page(batchSize, pageMetadata, blocks);
} else {
return new Page(batchSize, blocks);
}
}
Aggregations