Search in sources :

Example 1 with ConnectorPartitioningHandle

use of com.facebook.presto.spi.connector.ConnectorPartitioningHandle in project presto by prestodb.

the class RaptorMetadata method getNewTableLayout.

@Override
public Optional<ConnectorNewTableLayout> getNewTableLayout(ConnectorSession session, ConnectorTableMetadata metadata) {
    ImmutableMap.Builder<String, RaptorColumnHandle> map = ImmutableMap.builder();
    long columnId = 1;
    for (ColumnMetadata column : metadata.getColumns()) {
        map.put(column.getName(), new RaptorColumnHandle(connectorId, column.getName(), columnId, column.getType()));
        columnId++;
    }
    Optional<DistributionInfo> distribution = getOrCreateDistribution(map.build(), metadata.getProperties());
    if (!distribution.isPresent()) {
        return Optional.empty();
    }
    List<String> partitionColumns = distribution.get().getBucketColumns().stream().map(RaptorColumnHandle::getColumnName).collect(toList());
    ConnectorPartitioningHandle partitioning = getPartitioningHandle(distribution.get().getDistributionId());
    return Optional.of(new ConnectorNewTableLayout(partitioning, partitionColumns));
}
Also used : ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) ConnectorPartitioningHandle(com.facebook.presto.spi.connector.ConnectorPartitioningHandle) ConnectorNewTableLayout(com.facebook.presto.spi.ConnectorNewTableLayout) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 ConnectorNewTableLayout (com.facebook.presto.spi.ConnectorNewTableLayout)1 ConnectorPartitioningHandle (com.facebook.presto.spi.connector.ConnectorPartitioningHandle)1 ImmutableMap (com.google.common.collect.ImmutableMap)1