Search in sources :

Example 1 with PartitioningProviderManager

use of com.facebook.presto.sql.planner.PartitioningProviderManager in project presto by prestodb.

the class TaskTestUtils method createTestingPlanner.

public static LocalExecutionPlanner createTestingPlanner() {
    MetadataManager metadata = MetadataManager.createTestMetadataManager();
    PageSourceManager pageSourceManager = new PageSourceManager();
    pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
    // we don't start the finalizer so nothing will be collected, which is ok for a test
    FinalizerService finalizerService = new FinalizerService();
    NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
    return new LocalExecutionPlanner(metadata, Optional.empty(), pageSourceManager, new IndexManager(), partitioningProviderManager, nodePartitioningManager, new PageSinkManager(), new ConnectorMetadataUpdaterManager(), new ExpressionCompiler(metadata, pageFunctionCompiler), pageFunctionCompiler, new JoinFilterFunctionCompiler(metadata), new IndexJoinLookupStats(), new TaskManagerConfig(), new MemoryManagerConfig(), new GenericSpillerFactory((types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }), (types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, (types, partitionFunction, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, new BlockEncodingManager(), new PagesIndex.TestingFactory(false), new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig()), new LookupJoinOperators(), new OrderingCompiler(), jsonCodec(TableCommitContext.class), new RowExpressionDeterminismEvaluator(metadata), new NoOpFragmentResultCacheManager(), new ObjectMapper(), (session) -> {
        throw new UnsupportedOperationException();
    });
}
Also used : WarningCollector(com.facebook.presto.spi.WarningCollector) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) MetadataManager(com.facebook.presto.metadata.MetadataManager) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) EventListenerManager(com.facebook.presto.eventlistener.EventListenerManager) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) TableWriteInfo(com.facebook.presto.execution.scheduler.TableWriteInfo) PagesIndex(com.facebook.presto.operator.PagesIndex) StageExecutionDescriptor(com.facebook.presto.operator.StageExecutionDescriptor) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) NoOpFragmentResultCacheManager(com.facebook.presto.operator.NoOpFragmentResultCacheManager) FinalizerService(com.facebook.presto.util.FinalizerService) JsonObjectMapperProvider(com.facebook.airlift.json.JsonObjectMapperProvider) PartitioningScheme(com.facebook.presto.sql.planner.PartitioningScheme) URI(java.net.URI) PageFunctionCompiler(com.facebook.presto.sql.gen.PageFunctionCompiler) ConnectorMetadataUpdaterManager(com.facebook.presto.metadata.ConnectorMetadataUpdaterManager) ImmutableSet(com.google.common.collect.ImmutableSet) PageSinkManager(com.facebook.presto.split.PageSinkManager) ImmutableMap(com.google.common.collect.ImmutableMap) ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) JsonCodec.jsonCodec(com.facebook.airlift.json.JsonCodec.jsonCodec) SOURCE_DISTRIBUTION(com.facebook.presto.sql.planner.SystemPartitioningHandle.SOURCE_DISTRIBUTION) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) List(java.util.List) Optional(java.util.Optional) ConnectorId(com.facebook.presto.spi.ConnectorId) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) OutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers) SINGLE_DISTRIBUTION(com.facebook.presto.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) TestingSplit(com.facebook.presto.testing.TestingSplit) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) PageSourceManager(com.facebook.presto.split.PageSourceManager) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) BlockEncodingManager(com.facebook.presto.common.block.BlockEncodingManager) GenericSpillerFactory(com.facebook.presto.spiller.GenericSpillerFactory) IndexManager(com.facebook.presto.index.IndexManager) TableHandle(com.facebook.presto.spi.TableHandle) MemoryManagerConfig(com.facebook.presto.memory.MemoryManagerConfig) PlanFragmentId(com.facebook.presto.sql.planner.plan.PlanFragmentId) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) TransactionManager(com.facebook.presto.transaction.TransactionManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) Partitioning(com.facebook.presto.sql.planner.Partitioning) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) TableCommitContext(com.facebook.presto.operator.TableCommitContext) SplitMonitor(com.facebook.presto.event.SplitMonitor) Executor(java.util.concurrent.Executor) Session(com.facebook.presto.Session) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JoinFilterFunctionCompiler(com.facebook.presto.sql.gen.JoinFilterFunctionCompiler) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) TestingColumnHandle(com.facebook.presto.testing.TestingMetadata.TestingColumnHandle) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) StatsAndCosts(com.facebook.presto.cost.StatsAndCosts) Split(com.facebook.presto.metadata.Split) TestingTableHandle(com.facebook.presto.testing.TestingMetadata.TestingTableHandle) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) PageFunctionCompiler(com.facebook.presto.sql.gen.PageFunctionCompiler) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) TableCommitContext(com.facebook.presto.operator.TableCommitContext) PagesIndex(com.facebook.presto.operator.PagesIndex) PageSourceManager(com.facebook.presto.split.PageSourceManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) NoOpFragmentResultCacheManager(com.facebook.presto.operator.NoOpFragmentResultCacheManager) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) GenericSpillerFactory(com.facebook.presto.spiller.GenericSpillerFactory) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PageSinkManager(com.facebook.presto.split.PageSinkManager) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) JoinFilterFunctionCompiler(com.facebook.presto.sql.gen.JoinFilterFunctionCompiler) MemoryManagerConfig(com.facebook.presto.memory.MemoryManagerConfig) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) IndexManager(com.facebook.presto.index.IndexManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) MetadataManager(com.facebook.presto.metadata.MetadataManager) BlockEncodingManager(com.facebook.presto.common.block.BlockEncodingManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) ConnectorMetadataUpdaterManager(com.facebook.presto.metadata.ConnectorMetadataUpdaterManager) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler)

Example 2 with PartitioningProviderManager

use of com.facebook.presto.sql.planner.PartitioningProviderManager in project presto by prestodb.

the class TestLocalExchange method testCreatePartitionFunction.

@Test
public void testCreatePartitionFunction() {
    int partitionCount = 10;
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    partitioningProviderManager.addPartitioningProvider(new ConnectorId("prism"), new ConnectorNodePartitioningProvider() {

        @Override
        public ConnectorBucketNodeMap getBucketNodeMap(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle, List<Node> sortedNodes) {
            return createBucketNodeMap(Stream.generate(() -> sortedNodes).flatMap(List::stream).limit(10).collect(toImmutableList()), SOFT_AFFINITY);
        }

        @Override
        public ToIntFunction<ConnectorSplit> getSplitBucketFunction(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle) {
            return null;
        }

        @Override
        public BucketFunction getBucketFunction(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle, List<Type> partitionChannelTypes, int bucketCount) {
            return (Page page, int position) -> partitionCount;
        }

        @Override
        public int getBucketCount(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle) {
            return 10;
        }
    });
    PartitioningHandle partitioningHandle = new PartitioningHandle(Optional.of(new ConnectorId("prism")), Optional.of(new ConnectorTransactionHandle() {

        @Override
        public int hashCode() {
            return super.hashCode();
        }

        @Override
        public boolean equals(Object obj) {
            return super.equals(obj);
        }
    }), new ConnectorPartitioningHandle() {

        @Override
        public boolean isSingleNode() {
            return false;
        }

        @Override
        public boolean isCoordinatorOnly() {
            return false;
        }
    });
    PartitionFunction partitionFunction = createPartitionFunction(partitioningProviderManager, session, partitioningHandle, 600, ImmutableList.of(), false);
    assertEquals(partitionFunction.getPartitionCount(), partitionCount);
}
Also used : LocalExchange.createPartitionFunction(com.facebook.presto.operator.exchange.LocalExchange.createPartitionFunction) PartitionFunction(com.facebook.presto.operator.PartitionFunction) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) Node(com.facebook.presto.spi.Node) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) Page(com.facebook.presto.common.Page) Type(com.facebook.presto.common.type.Type) ConnectorPartitioningHandle(com.facebook.presto.spi.connector.ConnectorPartitioningHandle) ConnectorNodePartitioningProvider(com.facebook.presto.spi.connector.ConnectorNodePartitioningProvider) ConnectorBucketNodeMap(com.facebook.presto.spi.connector.ConnectorBucketNodeMap) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ToIntFunction(java.util.function.ToIntFunction) ConnectorPartitioningHandle(com.facebook.presto.spi.connector.ConnectorPartitioningHandle) PartitioningHandle(com.facebook.presto.sql.planner.PartitioningHandle) BucketFunction(com.facebook.presto.spi.BucketFunction) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Example 3 with PartitioningProviderManager

use of com.facebook.presto.sql.planner.PartitioningProviderManager in project presto by prestodb.

the class TestLocalExchange method setUp.

@BeforeClass
public void setUp() {
    partitioningProviderManager = new PartitioningProviderManager();
    session = testSessionBuilder().build();
}
Also used : PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with PartitioningProviderManager

use of com.facebook.presto.sql.planner.PartitioningProviderManager in project presto by prestodb.

the class TestCostCalculator method setUp.

@BeforeClass
public void setUp() {
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES);
    costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator);
    costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator);
    session = testSessionBuilder().setCatalog("tpch").build();
    CatalogManager catalogManager = new CatalogManager();
    catalogManager.registerCatalog(createBogusTestingCatalog("tpch"));
    transactionManager = createTestTransactionManager(catalogManager);
    metadata = createTestMetadataManager(transactionManager, new FeaturesConfig());
    finalizerService = new FinalizerService();
    finalizerService.start();
    nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig(), new SqlParser(), new FeaturesConfig());
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) SqlParser(com.facebook.presto.sql.parser.SqlParser) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanFragmenter(com.facebook.presto.sql.planner.PlanFragmenter) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with PartitioningProviderManager

use of com.facebook.presto.sql.planner.PartitioningProviderManager in project presto by prestodb.

the class TestHashJoinOperator method setUp.

@BeforeMethod
public void setUp() {
    // Before/AfterMethod is chosen here because the executor needs to be shutdown
    // after every single test case to terminate outstanding threads, if any.
    // The line below is the same as newCachedThreadPool(daemonThreadsNamed(...)) except RejectionExecutionHandler.
    // RejectionExecutionHandler is set to DiscardPolicy (instead of the default AbortPolicy) here.
    // Otherwise, a large number of RejectedExecutionException will flood logging, resulting in Travis failure.
    executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, SECONDS, new SynchronousQueue<>(), daemonThreadsNamed("test-executor-%s"), new ThreadPoolExecutor.DiscardPolicy());
    scheduledExecutor = newScheduledThreadPool(2, daemonThreadsNamed("test-scheduledExecutor-%s"));
    partitioningProviderManager = new PartitioningProviderManager();
    session = testSessionBuilder().build();
}
Also used : SynchronousQueue(java.util.concurrent.SynchronousQueue) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

PartitioningProviderManager (com.facebook.presto.sql.planner.PartitioningProviderManager)7 NoOpQueryManager (com.facebook.presto.dispatcher.NoOpQueryManager)2 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)2 LegacyNetworkTopology (com.facebook.presto.execution.scheduler.LegacyNetworkTopology)2 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)2 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)2 NodeSelectionStats (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats)2 SimpleTtlNodeSelectorConfig (com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig)2 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)2 ConnectorId (com.facebook.presto.spi.ConnectorId)2 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)2 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)2 SqlParser (com.facebook.presto.sql.parser.SqlParser)2 PlanFragmenter (com.facebook.presto.sql.planner.PlanFragmenter)2 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 JsonCodec.jsonCodec (com.facebook.airlift.json.JsonCodec.jsonCodec)1 JsonObjectMapperProvider (com.facebook.airlift.json.JsonObjectMapperProvider)1 Session (com.facebook.presto.Session)1 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1