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()));
}
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()));
}
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()));
}
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());
}
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);
}
Aggregations