Search in sources :

Example 1 with PrestoThriftColumnMetadata

use of com.facebook.presto.thrift.api.connector.PrestoThriftColumnMetadata in project presto by prestodb.

the class ThriftTpchService method getTableMetadata.

@Override
public final PrestoThriftNullableTableMetadata getTableMetadata(PrestoThriftSchemaTableName schemaTableName) {
    String schemaName = schemaTableName.getSchemaName();
    String tableName = schemaTableName.getTableName();
    if (!SCHEMAS.contains(schemaName) || TpchTable.getTables().stream().noneMatch(table -> table.getTableName().equals(tableName))) {
        return new PrestoThriftNullableTableMetadata(null);
    }
    TpchTable<?> tpchTable = TpchTable.getTable(schemaTableName.getTableName());
    List<PrestoThriftColumnMetadata> columns = new ArrayList<>();
    for (TpchColumn<? extends TpchEntity> column : tpchTable.getColumns()) {
        columns.add(new PrestoThriftColumnMetadata(column.getSimplifiedColumnName(), getTypeString(column), null, false));
    }
    List<Set<String>> indexableKeys = getIndexableKeys(schemaName, tableName);
    return new PrestoThriftNullableTableMetadata(new PrestoThriftTableMetadata(schemaTableName, columns, null, !indexableKeys.isEmpty() ? indexableKeys : null));
}
Also used : RecordPageSource(com.facebook.presto.spi.RecordPageSource) PrestoThriftNullableSchemaName(com.facebook.presto.thrift.api.connector.PrestoThriftNullableSchemaName) TpchColumn(io.airlift.tpch.TpchColumn) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) JsonCodec(com.facebook.airlift.json.JsonCodec) Page(com.facebook.presto.common.Page) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PrestoThriftNullableTableMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftNullableTableMetadata) PrestoThriftNullableColumnSet(com.facebook.presto.thrift.api.connector.PrestoThriftNullableColumnSet) TpchRecordSet.createTpchRecordSet(com.facebook.presto.tpch.TpchRecordSet.createTpchRecordSet) PrestoThriftSplitBatch(com.facebook.presto.thrift.api.connector.PrestoThriftSplitBatch) PrestoThriftPageResult(com.facebook.presto.thrift.api.connector.PrestoThriftPageResult) ArrayList(java.util.ArrayList) PreDestroy(javax.annotation.PreDestroy) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) PrestoThriftSchemaTableName(com.facebook.presto.thrift.api.connector.PrestoThriftSchemaTableName) PrestoThriftBlock(com.facebook.presto.thrift.api.datatypes.PrestoThriftBlock) SplitInfo.normalSplit(com.facebook.presto.connector.thrift.server.SplitInfo.normalSplit) PrestoThriftNullableToken(com.facebook.presto.thrift.api.connector.PrestoThriftNullableToken) PrestoThriftTupleDomain(com.facebook.presto.thrift.api.connector.PrestoThriftTupleDomain) PrestoThriftColumnMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftColumnMetadata) Type(com.facebook.presto.common.type.Type) Nullable(javax.annotation.Nullable) PrestoThriftService(com.facebook.presto.thrift.api.connector.PrestoThriftService) PrestoThriftServiceException(com.facebook.presto.thrift.api.connector.PrestoThriftServiceException) DEFAULT_MAX_PAGE_SIZE_IN_BYTES(com.facebook.presto.common.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES) Threads.threadsNamed(com.facebook.airlift.concurrent.Threads.threadsNamed) Set(java.util.Set) PrestoThriftBlock.fromBlock(com.facebook.presto.thrift.api.datatypes.PrestoThriftBlock.fromBlock) Math.min(java.lang.Math.min) PrestoThriftId(com.facebook.presto.thrift.api.connector.PrestoThriftId) JsonCodec.jsonCodec(com.facebook.airlift.json.JsonCodec.jsonCodec) PrestoThriftSplit(com.facebook.presto.thrift.api.connector.PrestoThriftSplit) Ints(com.google.common.primitives.Ints) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) Executors.newFixedThreadPool(java.util.concurrent.Executors.newFixedThreadPool) Preconditions.checkState(com.google.common.base.Preconditions.checkState) TpchTable(io.airlift.tpch.TpchTable) TpchEntity(io.airlift.tpch.TpchEntity) TpchMetadata.getPrestoType(com.facebook.presto.tpch.TpchMetadata.getPrestoType) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) PrestoThriftTableMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftTableMetadata) Closeable(java.io.Closeable) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) PrestoThriftNullableTableMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftNullableTableMetadata) PrestoThriftNullableColumnSet(com.facebook.presto.thrift.api.connector.PrestoThriftNullableColumnSet) TpchRecordSet.createTpchRecordSet(com.facebook.presto.tpch.TpchRecordSet.createTpchRecordSet) Set(java.util.Set) ArrayList(java.util.ArrayList) PrestoThriftColumnMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftColumnMetadata) PrestoThriftTableMetadata(com.facebook.presto.thrift.api.connector.PrestoThriftTableMetadata)

Aggregations

Threads.threadsNamed (com.facebook.airlift.concurrent.Threads.threadsNamed)1 JsonCodec (com.facebook.airlift.json.JsonCodec)1 JsonCodec.jsonCodec (com.facebook.airlift.json.JsonCodec.jsonCodec)1 Page (com.facebook.presto.common.Page)1 DEFAULT_MAX_PAGE_SIZE_IN_BYTES (com.facebook.presto.common.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES)1 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)1 Type (com.facebook.presto.common.type.Type)1 SplitInfo.normalSplit (com.facebook.presto.connector.thrift.server.SplitInfo.normalSplit)1 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)1 RecordPageSource (com.facebook.presto.spi.RecordPageSource)1 PrestoThriftColumnMetadata (com.facebook.presto.thrift.api.connector.PrestoThriftColumnMetadata)1 PrestoThriftId (com.facebook.presto.thrift.api.connector.PrestoThriftId)1 PrestoThriftNullableColumnSet (com.facebook.presto.thrift.api.connector.PrestoThriftNullableColumnSet)1 PrestoThriftNullableSchemaName (com.facebook.presto.thrift.api.connector.PrestoThriftNullableSchemaName)1 PrestoThriftNullableTableMetadata (com.facebook.presto.thrift.api.connector.PrestoThriftNullableTableMetadata)1 PrestoThriftNullableToken (com.facebook.presto.thrift.api.connector.PrestoThriftNullableToken)1 PrestoThriftPageResult (com.facebook.presto.thrift.api.connector.PrestoThriftPageResult)1 PrestoThriftSchemaTableName (com.facebook.presto.thrift.api.connector.PrestoThriftSchemaTableName)1 PrestoThriftService (com.facebook.presto.thrift.api.connector.PrestoThriftService)1 PrestoThriftServiceException (com.facebook.presto.thrift.api.connector.PrestoThriftServiceException)1