Search in sources :

Example 16 with ConnectorTableLayoutResult

use of com.facebook.presto.spi.ConnectorTableLayoutResult in project presto by prestodb.

the class TestRaptorSplitManager method testSanity.

@Test
public void testSanity() throws InterruptedException {
    List<ConnectorTableLayoutResult> layouts = metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty());
    assertEquals(layouts.size(), 1);
    ConnectorTableLayoutResult layout = getOnlyElement(layouts);
    assertInstanceOf(layout.getTableLayout().getHandle(), RaptorTableLayoutHandle.class);
    ConnectorSplitSource splitSource = getSplits(raptorSplitManager, layout);
    int splitCount = 0;
    while (!splitSource.isFinished()) {
        splitCount += getFutureValue(splitSource.getNextBatch(1000)).size();
    }
    assertEquals(splitCount, 4);
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) Constraint(com.facebook.presto.spi.Constraint) Test(org.testng.annotations.Test)

Example 17 with ConnectorTableLayoutResult

use of com.facebook.presto.spi.ConnectorTableLayoutResult in project presto by prestodb.

the class RedisMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    RedisTableHandle tableHandle = convertTableHandle(table);
    ConnectorTableLayout layout = new ConnectorTableLayout(new RedisTableLayoutHandle(tableHandle));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 18 with ConnectorTableLayoutResult

use of com.facebook.presto.spi.ConnectorTableLayoutResult in project presto by prestodb.

the class ConnectorMetadata method getInsertLayout.

/**
     * Get the physical layout for a inserting into an existing table.
     */
default default Optional<ConnectorNewTableLayout> getInsertLayout(ConnectorSession session, ConnectorTableHandle tableHandle) {
    List<ConnectorTableLayout> layouts = getTableLayouts(session, tableHandle, new Constraint<>(TupleDomain.all(), map -> true), Optional.empty()).stream().map(ConnectorTableLayoutResult::getTableLayout).filter(layout -> layout.getNodePartitioning().isPresent()).collect(toList());
    if (layouts.isEmpty()) {
        return Optional.empty();
    }
    if (layouts.size() > 1) {
        throw new PrestoException(NOT_SUPPORTED, "Tables with multiple layouts can not be written");
    }
    ConnectorTableLayout layout = layouts.get(0);
    ConnectorPartitioningHandle partitioningHandle = layout.getNodePartitioning().get().getPartitioningHandle();
    Map<ColumnHandle, String> columnNamesByHandle = getColumnHandles(session, tableHandle).entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
    List<String> partitionColumns = layout.getNodePartitioning().get().getPartitioningColumns().stream().map(columnNamesByHandle::get).collect(toList());
    return Optional.of(new ConnectorNewTableLayout(partitioningHandle, partitionColumns));
}
Also used : Slice(io.airlift.slice.Slice) ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) GENERIC_INTERNAL_ERROR(com.facebook.presto.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) ConnectorOutputTableHandle(com.facebook.presto.spi.ConnectorOutputTableHandle) PrestoException(com.facebook.presto.spi.PrestoException) TableIdentity(com.facebook.presto.spi.TableIdentity) Privilege(com.facebook.presto.spi.security.Privilege) OptionalLong(java.util.OptionalLong) SchemaTableName(com.facebook.presto.spi.SchemaTableName) Map(java.util.Map) ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptyList(java.util.Collections.emptyList) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) Collection(java.util.Collection) ColumnIdentity(com.facebook.presto.spi.ColumnIdentity) Set(java.util.Set) Constraint(com.facebook.presto.spi.Constraint) ConnectorResolvedIndex(com.facebook.presto.spi.ConnectorResolvedIndex) Collectors(java.util.stream.Collectors) ConnectorSession(com.facebook.presto.spi.ConnectorSession) TupleDomain(com.facebook.presto.spi.predicate.TupleDomain) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) SchemaTablePrefix(com.facebook.presto.spi.SchemaTablePrefix) NOT_SUPPORTED(com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED) ColumnHandle(com.facebook.presto.spi.ColumnHandle) ConnectorNewTableLayout(com.facebook.presto.spi.ConnectorNewTableLayout) Optional(java.util.Optional) ConnectorViewDefinition(com.facebook.presto.spi.ConnectorViewDefinition) ColumnHandle(com.facebook.presto.spi.ColumnHandle) PrestoException(com.facebook.presto.spi.PrestoException) ConnectorNewTableLayout(com.facebook.presto.spi.ConnectorNewTableLayout) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) Map(java.util.Map) Collections.emptyMap(java.util.Collections.emptyMap)

Example 19 with ConnectorTableLayoutResult

use of com.facebook.presto.spi.ConnectorTableLayoutResult in project presto by prestodb.

the class BlackHoleMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle handle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    BlackHoleTableHandle blackHoleHandle = (BlackHoleTableHandle) handle;
    BlackHoleTableLayoutHandle layoutHandle = new BlackHoleTableLayoutHandle(blackHoleHandle.getSplitCount(), blackHoleHandle.getPagesPerSplit(), blackHoleHandle.getRowsPerPage(), blackHoleHandle.getFieldsLength(), blackHoleHandle.getPageProcessingDelay());
    return ImmutableList.of(new ConnectorTableLayoutResult(getTableLayout(session, layoutHandle), TupleDomain.all()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult)

Example 20 with ConnectorTableLayoutResult

use of com.facebook.presto.spi.ConnectorTableLayoutResult in project presto by prestodb.

the class JdbcMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    JdbcTableHandle tableHandle = (JdbcTableHandle) table;
    ConnectorTableLayout layout = new ConnectorTableLayout(new JdbcTableLayoutHandle(tableHandle, constraint.getSummary()));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Aggregations

ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)38 ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)28 ColumnHandle (com.facebook.presto.spi.ColumnHandle)20 Test (org.testng.annotations.Test)19 ConnectorSplitSource (com.facebook.presto.spi.ConnectorSplitSource)18 Constraint (com.facebook.presto.spi.Constraint)18 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)17 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)17 Map (java.util.Map)17 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)16 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)16 ConnectorSession (com.facebook.presto.spi.ConnectorSession)16 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)16 SchemaTableName (com.facebook.presto.spi.SchemaTableName)16 TupleDomain (com.facebook.presto.spi.predicate.TupleDomain)16 ImmutableList (com.google.common.collect.ImmutableList)16 ImmutableMap (com.google.common.collect.ImmutableMap)16 Set (java.util.Set)16 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)15 GroupByHashPageIndexerFactory (com.facebook.presto.GroupByHashPageIndexerFactory)14