Search in sources :

Example 1 with PrestoThriftColumnMetadata

use of io.prestosql.plugin.thrift.api.PrestoThriftColumnMetadata in project hetu-core by openlookeng.

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 : PrestoThriftTableMetadata(io.prestosql.plugin.thrift.api.PrestoThriftTableMetadata) TpchColumn(io.airlift.tpch.TpchColumn) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitInfo.normalSplit(io.prestosql.plugin.thrift.server.SplitInfo.normalSplit) PrestoThriftNullableTableMetadata(io.prestosql.plugin.thrift.api.PrestoThriftNullableTableMetadata) PrestoThriftNullableSchemaName(io.prestosql.plugin.thrift.api.PrestoThriftNullableSchemaName) PrestoThriftBlock(io.prestosql.plugin.thrift.api.PrestoThriftBlock) PrestoThriftSchemaTableName(io.prestosql.plugin.thrift.api.PrestoThriftSchemaTableName) ArrayList(java.util.ArrayList) PrestoThriftPageResult(io.prestosql.plugin.thrift.api.PrestoThriftPageResult) PreDestroy(javax.annotation.PreDestroy) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableList(com.google.common.collect.ImmutableList) PrestoThriftColumnMetadata(io.prestosql.plugin.thrift.api.PrestoThriftColumnMetadata) Type(io.prestosql.spi.type.Type) PrestoThriftService(io.prestosql.plugin.thrift.api.PrestoThriftService) Nullable(javax.annotation.Nullable) DEFAULT_MAX_PAGE_SIZE_IN_BYTES(io.prestosql.spi.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES) PrestoThriftTupleDomain(io.prestosql.plugin.thrift.api.PrestoThriftTupleDomain) PrestoThriftServiceException(io.prestosql.plugin.thrift.api.PrestoThriftServiceException) TpchMetadata.getPrestoType(io.prestosql.plugin.tpch.TpchMetadata.getPrestoType) PrestoThriftId(io.prestosql.plugin.thrift.api.PrestoThriftId) TupleDomain(io.prestosql.spi.predicate.TupleDomain) Set(java.util.Set) Page(io.prestosql.spi.Page) PrestoThriftSplitBatch(io.prestosql.plugin.thrift.api.PrestoThriftSplitBatch) Math.min(java.lang.Math.min) Threads.threadsNamed(io.airlift.concurrent.Threads.threadsNamed) Ints(com.google.common.primitives.Ints) PrestoThriftSplit(io.prestosql.plugin.thrift.api.PrestoThriftSplit) PrestoThriftNullableToken(io.prestosql.plugin.thrift.api.PrestoThriftNullableToken) Executors.newFixedThreadPool(java.util.concurrent.Executors.newFixedThreadPool) PrestoThriftNullableColumnSet(io.prestosql.plugin.thrift.api.PrestoThriftNullableColumnSet) Preconditions.checkState(com.google.common.base.Preconditions.checkState) TpchTable(io.airlift.tpch.TpchTable) JsonCodec.jsonCodec(io.airlift.json.JsonCodec.jsonCodec) TpchEntity(io.airlift.tpch.TpchEntity) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ConnectorPageSource(io.prestosql.spi.connector.ConnectorPageSource) Closeable(java.io.Closeable) PrestoThriftBlock.fromBlock(io.prestosql.plugin.thrift.api.PrestoThriftBlock.fromBlock) RecordPageSource(io.prestosql.spi.connector.RecordPageSource) TpchRecordSet.createTpchRecordSet(io.prestosql.plugin.tpch.TpchRecordSet.createTpchRecordSet) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) JsonCodec(io.airlift.json.JsonCodec) PrestoThriftNullableTableMetadata(io.prestosql.plugin.thrift.api.PrestoThriftNullableTableMetadata) Set(java.util.Set) PrestoThriftNullableColumnSet(io.prestosql.plugin.thrift.api.PrestoThriftNullableColumnSet) TpchRecordSet.createTpchRecordSet(io.prestosql.plugin.tpch.TpchRecordSet.createTpchRecordSet) ArrayList(java.util.ArrayList) PrestoThriftColumnMetadata(io.prestosql.plugin.thrift.api.PrestoThriftColumnMetadata) PrestoThriftTableMetadata(io.prestosql.plugin.thrift.api.PrestoThriftTableMetadata)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 Ints (com.google.common.primitives.Ints)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 MoreExecutors.listeningDecorator (com.google.common.util.concurrent.MoreExecutors.listeningDecorator)1 Threads.threadsNamed (io.airlift.concurrent.Threads.threadsNamed)1 JsonCodec (io.airlift.json.JsonCodec)1 JsonCodec.jsonCodec (io.airlift.json.JsonCodec.jsonCodec)1 TpchColumn (io.airlift.tpch.TpchColumn)1 TpchEntity (io.airlift.tpch.TpchEntity)1 TpchTable (io.airlift.tpch.TpchTable)1 PrestoThriftBlock (io.prestosql.plugin.thrift.api.PrestoThriftBlock)1 PrestoThriftBlock.fromBlock (io.prestosql.plugin.thrift.api.PrestoThriftBlock.fromBlock)1 PrestoThriftColumnMetadata (io.prestosql.plugin.thrift.api.PrestoThriftColumnMetadata)1 PrestoThriftId (io.prestosql.plugin.thrift.api.PrestoThriftId)1 PrestoThriftNullableColumnSet (io.prestosql.plugin.thrift.api.PrestoThriftNullableColumnSet)1 PrestoThriftNullableSchemaName (io.prestosql.plugin.thrift.api.PrestoThriftNullableSchemaName)1 PrestoThriftNullableTableMetadata (io.prestosql.plugin.thrift.api.PrestoThriftNullableTableMetadata)1