Search in sources :

Example 16 with FixedSplitSource

use of io.trino.spi.connector.FixedSplitSource in project trino by trinodb.

the class TpchSplitManager method getSplits.

@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableHandle table, SplitSchedulingStrategy splitSchedulingStrategy, DynamicFilter dynamicFilter) {
    Set<Node> nodes = nodeManager.getRequiredWorkerNodes();
    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;
    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
        for (int i = 0; i < splitsPerNode; i++) {
            splits.add(new TpchSplit(partNumber, totalParts, ImmutableList.of(node.getHostAndPort())));
            partNumber++;
        }
    }
    return new FixedSplitSource(splits.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) FixedSplitSource(io.trino.spi.connector.FixedSplitSource) Node(io.trino.spi.Node) ConnectorSplit(io.trino.spi.connector.ConnectorSplit)

Aggregations

FixedSplitSource (io.trino.spi.connector.FixedSplitSource)16 ConnectorSplit (io.trino.spi.connector.ConnectorSplit)12 ImmutableList (com.google.common.collect.ImmutableList)11 HostAddress (io.trino.spi.HostAddress)6 ConnectorSession (io.trino.spi.connector.ConnectorSession)5 ConnectorSplitManager (io.trino.spi.connector.ConnectorSplitManager)5 ConnectorSplitSource (io.trino.spi.connector.ConnectorSplitSource)5 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)5 ConnectorTransactionHandle (io.trino.spi.connector.ConnectorTransactionHandle)5 DynamicFilter (io.trino.spi.connector.DynamicFilter)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Objects.requireNonNull (java.util.Objects.requireNonNull)5 Optional (java.util.Optional)5 Inject (javax.inject.Inject)5 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 TrinoException (io.trino.spi.TrinoException)4 Lists (com.google.common.collect.Lists)3 Node (io.trino.spi.Node)3 ColumnHandle (io.trino.spi.connector.ColumnHandle)3