Search in sources :

Example 1 with ColumnMapping

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);
    }
}
Also used : LazyBlock(com.facebook.presto.spi.block.LazyBlock) Block(com.facebook.presto.spi.block.Block) LazyBlock(com.facebook.presto.spi.block.LazyBlock) RunLengthEncodedBlock(com.facebook.presto.spi.block.RunLengthEncodedBlock) Page(com.facebook.presto.spi.Page) PrestoException(com.facebook.presto.spi.PrestoException) ColumnMapping(com.facebook.presto.hive.HivePageSourceProvider.ColumnMapping)

Aggregations

ColumnMapping (com.facebook.presto.hive.HivePageSourceProvider.ColumnMapping)1 Page (com.facebook.presto.spi.Page)1 PrestoException (com.facebook.presto.spi.PrestoException)1 Block (com.facebook.presto.spi.block.Block)1 LazyBlock (com.facebook.presto.spi.block.LazyBlock)1 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)1