use of com.facebook.presto.hive.HivePageSourceProvider.ColumnMapping in project presto by prestodb.
the class HivePageSource method getNextPage.
@Override
public Page getNextPage() {
try {
Block[] blocks = new Block[columnMappings.size()];
Page dataPage = delegate.getNextPage();
if (dataPage == null) {
return null;
}
int batchSize = dataPage.getPositionCount();
for (int fieldId = 0; fieldId < blocks.length; fieldId++) {
ColumnMapping columnMapping = columnMappings.get(fieldId);
if (columnMapping.isPrefilled()) {
blocks[fieldId] = RunLengthEncodedBlock.create(types[fieldId], prefilledValues[fieldId], batchSize);
} else {
blocks[fieldId] = dataPage.getBlock(columnMapping.getIndex());
if (coercers[fieldId] != null) {
blocks[fieldId] = new LazyBlock(batchSize, new CoercionLazyBlockLoader(blocks[fieldId], coercers[fieldId]));
}
}
}
return new Page(batchSize, blocks);
} catch (PrestoException e) {
closeWithSuppression(e);
throw e;
} catch (RuntimeException e) {
closeWithSuppression(e);
throw new PrestoException(HIVE_CURSOR_ERROR, e);
}
}
Aggregations