Search in sources :

Example 1 with TableStatsRow

use of com.facebook.presto.raptor.metadata.TableStatsRow in project presto by prestodb.

the class TableStatsSystemTable method buildPages.

private static List<Page> buildPages(MetadataDao dao, TupleDomain<Integer> tupleDomain) {
    Map<Integer, NullableValue> domainValues = extractFixedValues(tupleDomain).orElse(ImmutableMap.of());
    String schemaName = getStringValue(domainValues.get(getColumnIndex(METADATA, SCHEMA_NAME)));
    String tableName = getStringValue(domainValues.get(getColumnIndex(METADATA, TABLE_NAME)));
    PageListBuilder pageBuilder = new PageListBuilder(METADATA.getColumns().stream().map(ColumnMetadata::getType).collect(toList()));
    for (TableStatsRow row : dao.getTableStatsRows(schemaName, tableName)) {
        pageBuilder.beginRow();
        VARCHAR.writeSlice(pageBuilder.nextBlockBuilder(), utf8Slice(row.getSchemaName()));
        VARCHAR.writeSlice(pageBuilder.nextBlockBuilder(), utf8Slice(row.getTableName()));
        TIMESTAMP.writeLong(pageBuilder.nextBlockBuilder(), row.getCreateTime());
        TIMESTAMP.writeLong(pageBuilder.nextBlockBuilder(), row.getUpdateTime());
        BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getTableVersion());
        BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getShardCount());
        BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getRowCount());
        BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getCompressedSize());
        BIGINT.writeLong(pageBuilder.nextBlockBuilder(), row.getUncompressedSize());
    }
    return pageBuilder.build();
}
Also used : TableStatsRow(com.facebook.presto.raptor.metadata.TableStatsRow) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) NullableValue(com.facebook.presto.spi.predicate.NullableValue)

Aggregations

TableStatsRow (com.facebook.presto.raptor.metadata.TableStatsRow)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 NullableValue (com.facebook.presto.spi.predicate.NullableValue)1