Search in sources :

Example 1 with BucketFunction

use of io.prestosql.spi.connector.BucketFunction in project hetu-core by openlookeng.

the class NodePartitioningManager method getPartitionFunction.

public PartitionFunction getPartitionFunction(Session session, PartitioningScheme partitioningScheme, List<Type> partitionChannelTypes) {
    Optional<int[]> bucketToPartition = partitioningScheme.getBucketToPartition();
    checkArgument(bucketToPartition.isPresent(), "Bucket to partition must be set before a partition function can be created");
    PartitioningHandle partitioningHandle = partitioningScheme.getPartitioning().getHandle();
    BucketFunction bucketFunction;
    if (partitioningHandle.getConnectorHandle() instanceof SystemPartitioningHandle) {
        checkArgument(partitioningScheme.getBucketToPartition().isPresent(), "Bucket to partition must be set before a partition function can be created");
        return ((SystemPartitioningHandle) partitioningHandle.getConnectorHandle()).getPartitionFunction(partitionChannelTypes, partitioningScheme.getHashColumn().isPresent(), partitioningScheme.getBucketToPartition().get());
    }
    CatalogName catalogName = partitioningHandle.getConnectorId().get();
    ConnectorNodePartitioningProvider partitioningProvider = partitioningProviders.get(catalogName);
    checkArgument(partitioningProvider != null, "No partitioning provider for connector %s", catalogName);
    bucketFunction = partitioningProvider.getBucketFunction(partitioningHandle.getTransactionHandle().orElse(null), session.toConnectorSession(catalogName), partitioningHandle.getConnectorHandle(), partitionChannelTypes, bucketToPartition.get().length);
    checkArgument(bucketFunction != null, "No function %s", partitioningHandle);
    return new BucketPartitionFunction(bucketFunction, partitioningScheme.getBucketToPartition().get());
}
Also used : BucketPartitionFunction(io.prestosql.operator.BucketPartitionFunction) ConnectorNodePartitioningProvider(io.prestosql.spi.connector.ConnectorNodePartitioningProvider) CatalogName(io.prestosql.spi.connector.CatalogName) BucketFunction(io.prestosql.spi.connector.BucketFunction)

Example 2 with BucketFunction

use of io.prestosql.spi.connector.BucketFunction in project hetu-core by openlookeng.

the class SystemPartitioningHandle method getPartitionFunction.

public PartitionFunction getPartitionFunction(List<Type> partitionChannelTypes, boolean isHashPrecomputed, int[] bucketToPartition) {
    requireNonNull(partitionChannelTypes, "partitionChannelTypes is null");
    requireNonNull(bucketToPartition, "bucketToPartition is null");
    BucketFunction bucketFunction = function.createBucketFunction(partitionChannelTypes, isHashPrecomputed, bucketToPartition.length);
    return new BucketPartitionFunction(bucketFunction, bucketToPartition);
}
Also used : BucketPartitionFunction(io.prestosql.operator.BucketPartitionFunction) BucketFunction(io.prestosql.spi.connector.BucketFunction)

Aggregations

BucketPartitionFunction (io.prestosql.operator.BucketPartitionFunction)2 BucketFunction (io.prestosql.spi.connector.BucketFunction)2 CatalogName (io.prestosql.spi.connector.CatalogName)1 ConnectorNodePartitioningProvider (io.prestosql.spi.connector.ConnectorNodePartitioningProvider)1