Search in sources :

Example 21 with ConnectorTableLayoutResult

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

the class JmxMetadata method getTableLayouts.

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

Example 22 with ConnectorTableLayoutResult

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

the class MemoryMetadata method getTableLayouts.

@Override
public synchronized List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle handle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    requireNonNull(handle, "handle is null");
    checkArgument(handle instanceof MemoryTableHandle);
    MemoryTableLayoutHandle layoutHandle = new MemoryTableLayoutHandle((MemoryTableHandle) handle);
    return ImmutableList.of(new ConnectorTableLayoutResult(getTableLayout(session, layoutHandle), constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult)

Example 23 with ConnectorTableLayoutResult

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

the class TpchMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    TpchTableHandle tableHandle = (TpchTableHandle) table;
    Optional<ConnectorNodePartitioning> nodePartition = Optional.empty();
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    List<LocalProperty<ColumnHandle>> localProperties = ImmutableList.of();
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    if (tableHandle.getTableName().equals(TpchTable.ORDERS.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(OrderColumn.ORDER_KEY.getColumnName());
        nodePartition = Optional.of(new ConnectorNodePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
        partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
        localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST));
    } else if (tableHandle.getTableName().equals(TpchTable.LINE_ITEM.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(OrderColumn.ORDER_KEY.getColumnName());
        nodePartition = Optional.of(new ConnectorNodePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
        partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
        localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST), new SortingProperty<>(columns.get(LineItemColumn.LINE_NUMBER.getColumnName()), SortOrder.ASC_NULLS_FIRST));
    }
    ConnectorTableLayout layout = new ConnectorTableLayout(new TpchTableLayoutHandle(tableHandle), Optional.empty(), // TODO: return well-known properties (e.g., orderkey > 0, etc)
    TupleDomain.all(), nodePartition, partitioningColumns, Optional.empty(), localProperties);
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) SortingProperty(com.facebook.presto.spi.SortingProperty) ConnectorNodePartitioning(com.facebook.presto.spi.ConnectorNodePartitioning) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) LocalProperty(com.facebook.presto.spi.LocalProperty)

Example 24 with ConnectorTableLayoutResult

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

the class TestRaptorSplitManager method testAssignRandomNodeWhenBackupAvailable.

@Test
public void testAssignRandomNodeWhenBackupAvailable() throws InterruptedException, URISyntaxException {
    TestingNodeManager nodeManager = new TestingNodeManager();
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    PrestoNode node = new PrestoNode(UUID.randomUUID().toString(), new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false);
    nodeManager.addNode(node);
    RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, true);
    deleteShardNodes();
    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource partitionSplit = getSplits(raptorSplitManagerWithBackup, layout);
    List<ConnectorSplit> batch = getFutureValue(partitionSplit.getNextBatch(1), PrestoException.class);
    assertEquals(getOnlyElement(getOnlyElement(batch).getAddresses()), node.getHostAndPort());
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) URI(java.net.URI) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) NodeSupplier(com.facebook.presto.raptor.NodeSupplier) PrestoNode(com.facebook.presto.metadata.PrestoNode) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) Test(org.testng.annotations.Test)

Example 25 with ConnectorTableLayoutResult

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

the class TestRaptorSplitManager method testNoNodes.

@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "No nodes available to run query")
public void testNoNodes() throws InterruptedException, URISyntaxException {
    deleteShardNodes();
    RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(new RaptorConnectorId("fbraptor"), ImmutableSet::of, shardManager, true);
    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource splitSource = getSplits(raptorSplitManagerWithBackup, layout);
    getFutureValue(splitSource.getNextBatch(1000), PrestoException.class);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) Test(org.testng.annotations.Test)

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