Search in sources :

Example 1 with Driver

use of io.prestosql.operator.Driver in project hetu-core by openlookeng.

the class LocalQueryRunner method executeInternal.

private MaterializedResultWithPlan executeInternal(Session session, @Language("SQL") String sql) {
    lock.readLock().lock();
    try (Closer closer = Closer.create()) {
        AtomicReference<MaterializedResult.Builder> builder = new AtomicReference<>();
        PageConsumerOutputFactory outputFactory = new PageConsumerOutputFactory(types -> {
            builder.compareAndSet(null, MaterializedResult.resultBuilder(session, types));
            return builder.get()::page;
        });
        TaskContext taskContext = TestingTaskContext.builder(notificationExecutor, yieldExecutor, session).setMaxSpillSize(nodeSpillConfig.getMaxSpillPerNode()).setQueryMaxSpillSize(nodeSpillConfig.getQueryMaxSpillPerNode()).build();
        Plan plan = createPlan(session, sql, WarningCollector.NOOP);
        List<Driver> drivers = createDrivers(session, plan, outputFactory, taskContext);
        drivers.forEach(closer::register);
        boolean done = false;
        while (!done) {
            boolean processed = false;
            for (Driver driver : drivers) {
                if (alwaysRevokeMemory) {
                    driver.getDriverContext().getOperatorContexts().stream().filter(operatorContext -> operatorContext.getOperatorStats().getRevocableMemoryReservation().getValue() > 0).forEach(OperatorContext::requestMemoryRevoking);
                }
                if (!driver.isFinished()) {
                    driver.process();
                    processed = true;
                }
            }
            done = !processed;
        }
        verify(builder.get() != null, "Output operator was not created");
        return new MaterializedResultWithPlan(builder.get().build(), plan);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    } finally {
        lock.readLock().unlock();
    }
}
Also used : Closer(com.google.common.io.Closer) CostCalculatorWithEstimatedExchanges(io.prestosql.cost.CostCalculatorWithEstimatedExchanges) RollbackTask(io.prestosql.execution.RollbackTask) FilterStatsCalculator(io.prestosql.cost.FilterStatsCalculator) Plan(io.prestosql.sql.planner.Plan) ConnectorManager(io.prestosql.connector.ConnectorManager) HttpServerConfig(io.airlift.http.server.HttpServerConfig) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) Prepare(io.prestosql.sql.tree.Prepare) Statement(io.prestosql.sql.tree.Statement) WarningCollector(io.prestosql.execution.warnings.WarningCollector) SnapshotConfig(io.prestosql.snapshot.SnapshotConfig) SchemaPropertiesSystemTable(io.prestosql.connector.system.SchemaPropertiesSystemTable) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) PlanSanityChecker(io.prestosql.sql.planner.sanity.PlanSanityChecker) Map(java.util.Map) TestingSession.createBogusTestingCatalog(io.prestosql.testing.TestingSession.createBogusTestingCatalog) TransactionBuilder.transaction(io.prestosql.transaction.TransactionBuilder.transaction) GlobalSystemConnector(io.prestosql.connector.system.GlobalSystemConnector) RenameColumn(io.prestosql.sql.tree.RenameColumn) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TransactionManagerConfig(io.prestosql.transaction.TransactionManagerConfig) RowExpressionDeterminismEvaluator(io.prestosql.sql.relational.RowExpressionDeterminismEvaluator) SetSessionTask(io.prestosql.execution.SetSessionTask) CostCalculatorUsingExchanges(io.prestosql.cost.CostCalculatorUsingExchanges) PageConsumerOutputFactory(io.prestosql.testing.PageConsumerOperator.PageConsumerOutputFactory) CommentTask(io.prestosql.execution.CommentTask) PlanNode(io.prestosql.spi.plan.PlanNode) NodeSchedulerConfig(io.prestosql.execution.scheduler.NodeSchedulerConfig) RowExpressionDomainTranslator(io.prestosql.sql.relational.RowExpressionDomainTranslator) ReuseExchangeOperator(io.prestosql.spi.operator.ReuseExchangeOperator) DropView(io.prestosql.sql.tree.DropView) PageSinkManager(io.prestosql.split.PageSinkManager) QueryPreparer(io.prestosql.execution.QueryPreparer) TaskManagerConfig(io.prestosql.execution.TaskManagerConfig) Plugin(io.prestosql.spi.Plugin) LocalExecutionPlanner(io.prestosql.sql.planner.LocalExecutionPlanner) EmbedVersion(io.prestosql.version.EmbedVersion) DropTable(io.prestosql.sql.tree.DropTable) TransactionManager(io.prestosql.transaction.TransactionManager) StageExecutionDescriptor(io.prestosql.operator.StageExecutionDescriptor) TaskContext(io.prestosql.operator.TaskContext) PlanPrinter(io.prestosql.sql.planner.planprinter.PlanPrinter) IndexJoinLookupStats(io.prestosql.operator.index.IndexJoinLookupStats) CommitTask(io.prestosql.execution.CommitTask) GenericSpillerFactory(io.prestosql.spiller.GenericSpillerFactory) ResetSession(io.prestosql.sql.tree.ResetSession) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) Deallocate(io.prestosql.sql.tree.Deallocate) ResetSessionTask(io.prestosql.execution.ResetSessionTask) MetadataUtil(io.prestosql.metadata.MetadataUtil) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ParsingUtil.createParsingOptions(io.prestosql.sql.ParsingUtil.createParsingOptions) NodeTaskMap(io.prestosql.execution.NodeTaskMap) SplitSource(io.prestosql.split.SplitSource) Comment(io.prestosql.sql.tree.Comment) SpillerFactory(io.prestosql.spiller.SpillerFactory) RenameTable(io.prestosql.sql.tree.RenameTable) DriverContext(io.prestosql.operator.DriverContext) TaskCountEstimator(io.prestosql.cost.TaskCountEstimator) Lifespan(io.prestosql.execution.Lifespan) StatsCalculatorModule.createNewStatsCalculator(io.prestosql.cost.StatsCalculatorModule.createNewStatsCalculator) CreateViewTask(io.prestosql.execution.CreateViewTask) IOException(java.io.IOException) GlobalSystemConnectorFactory(io.prestosql.connector.system.GlobalSystemConnectorFactory) DeallocateTask(io.prestosql.execution.DeallocateTask) CatalogManager(io.prestosql.metadata.CatalogManager) PlanOptimizer(io.prestosql.sql.planner.optimizations.PlanOptimizer) QueryExplainer(io.prestosql.sql.analyzer.QueryExplainer) SystemSessionProperties(io.prestosql.SystemSessionProperties) SqlParser(io.prestosql.sql.parser.SqlParser) QueryManagerConfig(io.prestosql.execution.QueryManagerConfig) Duration(io.airlift.units.Duration) TaskSource(io.prestosql.execution.TaskSource) HetuConfig(io.prestosql.utils.HetuConfig) ConnectorPlanOptimizerManager(io.prestosql.sql.planner.ConnectorPlanOptimizerManager) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) SetPathTask(io.prestosql.execution.SetPathTask) StartTransaction(io.prestosql.sql.tree.StartTransaction) Type(io.prestosql.spi.type.Type) StatsCalculator(io.prestosql.cost.StatsCalculator) PartitioningSpillerFactory(io.prestosql.spiller.PartitioningSpillerFactory) ImmutableSet(com.google.common.collect.ImmutableSet) CatalogName(io.prestosql.spi.connector.CatalogName) GenericPartitioningSpillerFactory(io.prestosql.spiller.GenericPartitioningSpillerFactory) Rollback(io.prestosql.sql.tree.Rollback) RenameColumnTask(io.prestosql.execution.RenameColumnTask) NodePartitioningManager(io.prestosql.sql.planner.NodePartitioningManager) NOT_PARTITIONED(io.prestosql.spi.connector.NotPartitionedPartitionHandle.NOT_PARTITIONED) Split(io.prestosql.metadata.Split) TableHandle(io.prestosql.spi.metadata.TableHandle) Function(java.util.function.Function) DynamicFilterCacheManager(io.prestosql.dynamicfilter.DynamicFilterCacheManager) LookupJoinOperators(io.prestosql.operator.LookupJoinOperators) PlanOptimizers(io.prestosql.sql.planner.PlanOptimizers) ImmutableList(com.google.common.collect.ImmutableList) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) PagesIndexPageSorter(io.prestosql.PagesIndexPageSorter) ExecutorService(java.util.concurrent.ExecutorService) IndexManager(io.prestosql.index.IndexManager) RenameIndex(io.prestosql.sql.tree.RenameIndex) PlanNodeSearcher.searchFrom(io.prestosql.sql.planner.optimizations.PlanNodeSearcher.searchFrom) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) JoinCompiler(io.prestosql.sql.gen.JoinCompiler) SpillerStats(io.prestosql.spiller.SpillerStats) GROUPED_SCHEDULING(io.prestosql.spi.connector.ConnectorSplitManager.SplitSchedulingStrategy.GROUPED_SCHEDULING) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) CostCalculator(io.prestosql.cost.CostCalculator) SubPlan(io.prestosql.sql.planner.SubPlan) NodeInfo(io.airlift.node.NodeInfo) RenameIndexTask(io.prestosql.execution.RenameIndexTask) NodeSystemTable(io.prestosql.connector.system.NodeSystemTable) StateStoreListenerManager(io.prestosql.statestore.listener.StateStoreListenerManager) CreateTable(io.prestosql.sql.tree.CreateTable) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) EventListenerManager(io.prestosql.eventlistener.EventListenerManager) PageIndexerFactory(io.prestosql.spi.PageIndexerFactory) OrderingCompiler(io.prestosql.sql.gen.OrderingCompiler) UNGROUPED_SCHEDULING(io.prestosql.spi.connector.ConnectorSplitManager.SplitSchedulingStrategy.UNGROUPED_SCHEDULING) SchemaPropertyManager(io.prestosql.metadata.SchemaPropertyManager) FileSingleStreamSpillerFactory(io.prestosql.spiller.FileSingleStreamSpillerFactory) TableScanNode(io.prestosql.spi.plan.TableScanNode) TablePropertiesSystemTable(io.prestosql.connector.system.TablePropertiesSystemTable) Metadata(io.prestosql.metadata.Metadata) MetadataManager(io.prestosql.metadata.MetadataManager) LogicalPlanner(io.prestosql.sql.planner.LogicalPlanner) SetSession(io.prestosql.sql.tree.SetSession) UncheckedIOException(java.io.UncheckedIOException) HttpServerInfo(io.airlift.http.server.HttpServerInfo) CreateView(io.prestosql.sql.tree.CreateView) CatalogSystemTable(io.prestosql.connector.system.CatalogSystemTable) Driver(io.prestosql.operator.Driver) PluginManager(io.prestosql.server.PluginManager) PreparedQuery(io.prestosql.execution.QueryPreparer.PreparedQuery) StartTransactionTask(io.prestosql.execution.StartTransactionTask) ExpressionCompiler(io.prestosql.sql.gen.ExpressionCompiler) SetPath(io.prestosql.sql.tree.SetPath) TESTING_CATALOG(io.prestosql.testing.TestingSession.TESTING_CATALOG) DropTableTask(io.prestosql.execution.DropTableTask) DataDefinitionTask(io.prestosql.execution.DataDefinitionTask) NodeScheduler(io.prestosql.execution.scheduler.NodeScheduler) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) ArrayList(java.util.ArrayList) CatalogConnectorStore(io.prestosql.connector.CatalogConnectorStore) GroupByHashPageIndexerFactory(io.prestosql.GroupByHashPageIndexerFactory) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) Closer(com.google.common.io.Closer) InMemoryNodeManager(io.prestosql.metadata.InMemoryNodeManager) EmbeddedStateStoreLauncher(io.prestosql.statestore.EmbeddedStateStoreLauncher) Session(io.prestosql.Session) PageSourceManager(io.prestosql.split.PageSourceManager) ScheduledSplit(io.prestosql.execution.ScheduledSplit) SessionPropertyDefaults(io.prestosql.server.SessionPropertyDefaults) TransactionsSystemTable(io.prestosql.connector.system.TransactionsSystemTable) Language(org.intellij.lang.annotations.Language) MoreFutures.getFutureValue(io.airlift.concurrent.MoreFutures.getFutureValue) CostComparator(io.prestosql.cost.CostComparator) FinalizerService(io.prestosql.util.FinalizerService) CubeManager(io.prestosql.cube.CubeManager) Lock(java.util.concurrent.locks.Lock) JoinFilterFunctionCompiler(io.prestosql.sql.gen.JoinFilterFunctionCompiler) TreeAssertions.assertFormattedSql(io.prestosql.sql.testing.TreeAssertions.assertFormattedSql) HandleResolver(io.prestosql.metadata.HandleResolver) ConnectorFactory(io.prestosql.spi.connector.ConnectorFactory) SplitManager(io.prestosql.split.SplitManager) QualifiedTablePrefix(io.prestosql.metadata.QualifiedTablePrefix) TablePropertyManager(io.prestosql.metadata.TablePropertyManager) TestingMBeanServer(org.weakref.jmx.testing.TestingMBeanServer) StatsNormalizer(io.prestosql.cost.StatsNormalizer) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Kryo(com.esotericsoftware.kryo.Kryo) AnalyzePropertiesSystemTable(io.prestosql.connector.system.AnalyzePropertiesSystemTable) ServerConfig(io.prestosql.server.ServerConfig) ColumnPropertyManager(io.prestosql.metadata.ColumnPropertyManager) PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) Commit(io.prestosql.sql.tree.Commit) ImmutableMap(com.google.common.collect.ImmutableMap) OutputFactory(io.prestosql.operator.OutputFactory) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PluginManagerConfig(io.prestosql.server.PluginManagerConfig) List(java.util.List) ColumnPropertiesSystemTable(io.prestosql.connector.system.ColumnPropertiesSystemTable) TableCommentSystemTable(io.prestosql.connector.system.TableCommentSystemTable) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) Optional(java.util.Optional) Analysis(io.prestosql.sql.analyzer.Analysis) NodeSpillConfig(io.prestosql.spiller.NodeSpillConfig) FunctionAndTypeManager(io.prestosql.metadata.FunctionAndTypeManager) MemoryManagerConfig(io.prestosql.memory.MemoryManagerConfig) LegacyNetworkTopology(io.prestosql.execution.scheduler.LegacyNetworkTopology) CreateTableTask(io.prestosql.execution.CreateTableTask) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) PlanFragmenter(io.prestosql.sql.planner.PlanFragmenter) DropViewTask(io.prestosql.execution.DropViewTask) PrepareTask(io.prestosql.execution.PrepareTask) Verify.verify(com.google.common.base.Verify.verify) Threads.daemonThreadsNamed(io.airlift.concurrent.Threads.daemonThreadsNamed) Objects.requireNonNull(java.util.Objects.requireNonNull) PasswordAuthenticatorManager(io.prestosql.server.security.PasswordAuthenticatorManager) PagesIndex(io.prestosql.operator.PagesIndex) ScalarStatsCalculator(io.prestosql.cost.ScalarStatsCalculator) OperatorContext(io.prestosql.operator.OperatorContext) DriverFactory(io.prestosql.operator.DriverFactory) AnalyzePropertyManager(io.prestosql.metadata.AnalyzePropertyManager) GroupProviderManager(io.prestosql.security.GroupProviderManager) PageSorter(io.prestosql.spi.PageSorter) LocalExecutionPlan(io.prestosql.sql.planner.LocalExecutionPlanner.LocalExecutionPlan) Analyzer(io.prestosql.sql.analyzer.Analyzer) TimeUnit(java.util.concurrent.TimeUnit) Executors.newCachedThreadPool(java.util.concurrent.Executors.newCachedThreadPool) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) RenameTableTask(io.prestosql.execution.RenameTableTask) MBeanExporter(org.weakref.jmx.MBeanExporter) Collections(java.util.Collections) TaskContext(io.prestosql.operator.TaskContext) PageConsumerOutputFactory(io.prestosql.testing.PageConsumerOperator.PageConsumerOutputFactory) Driver(io.prestosql.operator.Driver) AtomicReference(java.util.concurrent.atomic.AtomicReference) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Plan(io.prestosql.sql.planner.Plan) SubPlan(io.prestosql.sql.planner.SubPlan) LocalExecutionPlan(io.prestosql.sql.planner.LocalExecutionPlanner.LocalExecutionPlan) OperatorContext(io.prestosql.operator.OperatorContext)

Example 2 with Driver

use of io.prestosql.operator.Driver in project hetu-core by openlookeng.

the class TestSystemMemoryBlocking method testTableScanSystemMemoryBlocking.

@Test
public void testTableScanSystemMemoryBlocking() {
    PlanNodeId sourceId = new PlanNodeId("source");
    final List<Type> types = ImmutableList.of(VARCHAR);
    TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(1, new PlanNodeId("test"), "values"), sourceId, (session, split, table, columns, dynamicFilter) -> new FixedPageSource(rowPagesBuilder(types).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).addSequencePage(10, 1).build()), TEST_TABLE_HANDLE, ImmutableList.of(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), types, false, Optional.empty(), 0, 0);
    PageConsumerOperator sink = createSinkOperator(types);
    Driver driver = Driver.createDriver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    Split testSplit = new Split(new CatalogName("test"), new TestSplit(), Lifespan.taskWide());
    driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, testSplit)), true));
    ListenableFuture<?> blocked = driver.processFor(new Duration(1, NANOSECONDS));
    // the driver shouldn't block in the first call as it will be able to move a page between source and the sink operator
    // but the operator should be blocked
    assertTrue(blocked.isDone());
    assertFalse(source.getOperatorContext().isWaitingForMemory().isDone());
    // and they should stay blocked until more memory becomes available
    for (int i = 0; i < 10; i++) {
        blocked = driver.processFor(new Duration(1, NANOSECONDS));
        assertFalse(blocked.isDone());
        assertFalse(source.getOperatorContext().isWaitingForMemory().isDone());
    }
    // free up some memory
    memoryPool.free(QUERY_ID, "test", memoryPool.getReservedBytes());
    // the operator should be unblocked
    assertTrue(source.getOperatorContext().isWaitingForMemory().isDone());
    // the driver shouldn't be blocked
    blocked = driver.processFor(new Duration(1, NANOSECONDS));
    assertTrue(blocked.isDone());
}
Also used : TableScanOperator(io.prestosql.operator.TableScanOperator) ScheduledSplit(io.prestosql.execution.ScheduledSplit) Driver(io.prestosql.operator.Driver) Duration(io.airlift.units.Duration) FixedPageSource(io.prestosql.spi.connector.FixedPageSource) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageConsumerOperator(io.prestosql.testing.PageConsumerOperator) Type(io.prestosql.spi.type.Type) CatalogName(io.prestosql.spi.connector.CatalogName) UUID(java.util.UUID) ConnectorSplit(io.prestosql.spi.connector.ConnectorSplit) Split(io.prestosql.metadata.Split) ScheduledSplit(io.prestosql.execution.ScheduledSplit) TaskSource(io.prestosql.execution.TaskSource) Test(org.testng.annotations.Test)

Example 3 with Driver

use of io.prestosql.operator.Driver in project hetu-core by openlookeng.

the class HashBuildBenchmark method createDrivers.

@Override
protected List<Driver> createDrivers(TaskContext taskContext) {
    // hash build
    List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice");
    OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice");
    JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory(ordersTypes, ImmutableList.of(0, 1).stream().map(ordersTypes::get).collect(toImmutableList()), Ints.asList(0).stream().map(ordersTypes::get).collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false, false));
    HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory(1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory());
    DriverFactory hashBuildDriverFactory = new DriverFactory(0, true, true, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION);
    // empty join so build finishes
    ImmutableList.Builder<OperatorFactory> joinDriversBuilder = ImmutableList.builder();
    joinDriversBuilder.add(new ValuesOperatorFactory(0, new PlanNodeId("values"), ImmutableList.of()));
    OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(2, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(BIGINT), Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory());
    joinDriversBuilder.add(joinOperator);
    joinDriversBuilder.add(new NullOutputOperatorFactory(3, new PlanNodeId("test")));
    DriverFactory joinDriverFactory = new DriverFactory(1, true, true, joinDriversBuilder.build(), OptionalInt.empty(), UNGROUPED_EXECUTION);
    Driver hashBuildDriver = hashBuildDriverFactory.createDriver(taskContext.addPipelineContext(0, true, true, false).addDriverContext());
    hashBuildDriverFactory.noMoreDrivers();
    Driver joinDriver = joinDriverFactory.createDriver(taskContext.addPipelineContext(1, true, true, false).addDriverContext());
    joinDriverFactory.noMoreDrivers();
    return ImmutableList.of(hashBuildDriver, joinDriver);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.prestosql.operator.Driver) PagesIndex(io.prestosql.operator.PagesIndex) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) DriverFactory(io.prestosql.operator.DriverFactory) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) PartitionedLookupSourceFactory(io.prestosql.operator.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory)

Example 4 with Driver

use of io.prestosql.operator.Driver in project hetu-core by openlookeng.

the class HashJoinBenchmark method createDrivers.

/*
    select orderkey, quantity, totalprice
    from lineitem join orders using (orderkey)
     */
@Override
protected List<Driver> createDrivers(TaskContext taskContext) {
    if (probeDriverFactory == null) {
        List<Type> ordersTypes = getColumnTypes("orders", "orderkey", "totalprice");
        OperatorFactory ordersTableScan = createTableScanOperator(0, new PlanNodeId("test"), "orders", "orderkey", "totalprice");
        JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = JoinBridgeManager.lookupAllAtOnce(new PartitionedLookupSourceFactory(ordersTypes, ImmutableList.of(0, 1).stream().map(ordersTypes::get).collect(toImmutableList()), Ints.asList(0).stream().map(ordersTypes::get).collect(toImmutableList()), 1, requireNonNull(ImmutableMap.of(), "layout is null"), false, false));
        HashBuilderOperatorFactory hashBuilder = new HashBuilderOperatorFactory(1, new PlanNodeId("test"), lookupSourceFactoryManager, ImmutableList.of(0, 1), Ints.asList(0), OptionalInt.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), 1_500_000, new PagesIndex.TestingFactory(false), false, SingleStreamSpillerFactory.unsupportedSingleStreamSpillerFactory());
        DriverContext driverContext = taskContext.addPipelineContext(0, false, false, false).addDriverContext();
        DriverFactory buildDriverFactory = new DriverFactory(0, false, false, ImmutableList.of(ordersTableScan, hashBuilder), OptionalInt.empty(), UNGROUPED_EXECUTION);
        List<Type> lineItemTypes = getColumnTypes("lineitem", "orderkey", "quantity");
        OperatorFactory lineItemTableScan = createTableScanOperator(0, new PlanNodeId("test"), "lineitem", "orderkey", "quantity");
        OperatorFactory joinOperator = LOOKUP_JOIN_OPERATORS.innerJoin(1, new PlanNodeId("test"), lookupSourceFactoryManager, lineItemTypes, Ints.asList(0), OptionalInt.empty(), Optional.empty(), OptionalInt.empty(), unsupportedPartitioningSpillerFactory());
        NullOutputOperatorFactory output = new NullOutputOperatorFactory(2, new PlanNodeId("test"));
        this.probeDriverFactory = new DriverFactory(1, true, true, ImmutableList.of(lineItemTableScan, joinOperator, output), OptionalInt.empty(), UNGROUPED_EXECUTION);
        Driver driver = buildDriverFactory.createDriver(driverContext);
        Future<LookupSourceProvider> lookupSourceProvider = lookupSourceFactoryManager.getJoinBridge(Lifespan.taskWide()).createLookupSourceProvider();
        while (!lookupSourceProvider.isDone()) {
            driver.process();
        }
        getFutureValue(lookupSourceProvider).close();
    }
    DriverContext driverContext = taskContext.addPipelineContext(1, true, true, false).addDriverContext();
    Driver driver = probeDriverFactory.createDriver(driverContext);
    return ImmutableList.of(driver);
}
Also used : DriverContext(io.prestosql.operator.DriverContext) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) Driver(io.prestosql.operator.Driver) PagesIndex(io.prestosql.operator.PagesIndex) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) OperatorFactory(io.prestosql.operator.OperatorFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) DriverFactory(io.prestosql.operator.DriverFactory) PartitionedLookupSourceFactory(io.prestosql.operator.PartitionedLookupSourceFactory) NullOutputOperatorFactory(io.prestosql.testing.NullOutputOperator.NullOutputOperatorFactory) LookupSourceProvider(io.prestosql.operator.LookupSourceProvider)

Example 5 with Driver

use of io.prestosql.operator.Driver in project hetu-core by openlookeng.

the class MemoryLocalQueryRunner method execute.

public List<Page> execute(@Language("SQL") String query) {
    MemoryPool memoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(2, GIGABYTE));
    SpillSpaceTracker spillSpaceTracker = new SpillSpaceTracker(new DataSize(1, GIGABYTE));
    QueryContext queryContext = new QueryContext(new QueryId("test"), new DataSize(1, GIGABYTE), new DataSize(2, GIGABYTE), memoryPool, new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), new DataSize(4, GIGABYTE), spillSpaceTracker, NOOP_SNAPSHOT_UTILS);
    TaskContext taskContext = queryContext.addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), localQueryRunner.getExecutor()), localQueryRunner.getDefaultSession(), false, false, OptionalInt.empty(), Optional.empty(), TESTING_SERDE_FACTORY);
    // Use NullOutputFactory to avoid coping out results to avoid affecting benchmark results
    ImmutableList.Builder<Page> output = ImmutableList.builder();
    List<Driver> drivers = localQueryRunner.createDrivers(query, new PageConsumerOperator.PageConsumerOutputFactory(types -> output::add), taskContext);
    boolean done = false;
    while (!done) {
        boolean processed = false;
        for (Driver driver : drivers) {
            if (!driver.isFinished()) {
                driver.process();
                processed = true;
            }
        }
        done = !processed;
    }
    return output.build();
}
Also used : TESTING_SERDE_FACTORY(io.prestosql.testing.TestingPagesSerdeFactory.TESTING_SERDE_FACTORY) TaskId(io.prestosql.execution.TaskId) TaskStateMachine(io.prestosql.execution.TaskStateMachine) Plugin(io.prestosql.spi.Plugin) TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) SpillSpaceTracker(io.prestosql.spiller.SpillSpaceTracker) TaskContext(io.prestosql.operator.TaskContext) TableHandle(io.prestosql.spi.metadata.TableHandle) OptionalInt(java.util.OptionalInt) MemoryPool(io.prestosql.memory.MemoryPool) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) TestingSession.testSessionBuilder(io.prestosql.testing.TestingSession.testSessionBuilder) GIGABYTE(io.airlift.units.DataSize.Unit.GIGABYTE) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Session(io.prestosql.Session) QueryId(io.prestosql.spi.QueryId) PageConsumerOperator(io.prestosql.testing.PageConsumerOperator) ImmutableMap(com.google.common.collect.ImmutableMap) Language(org.intellij.lang.annotations.Language) NOOP_SNAPSHOT_UTILS(io.prestosql.testing.TestingSnapshotUtils.NOOP_SNAPSHOT_UTILS) Page(io.prestosql.spi.Page) QueryContext(io.prestosql.memory.QueryContext) MemoryConnectorFactory(io.prestosql.plugin.memory.MemoryConnectorFactory) MemoryPoolId(io.prestosql.spi.memory.MemoryPoolId) Metadata(io.prestosql.metadata.Metadata) DataSize(io.airlift.units.DataSize) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) List(java.util.List) Driver(io.prestosql.operator.Driver) Optional(java.util.Optional) Assert.assertTrue(org.testng.Assert.assertTrue) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) SpillSpaceTracker(io.prestosql.spiller.SpillSpaceTracker) TaskContext(io.prestosql.operator.TaskContext) TaskId(io.prestosql.execution.TaskId) ImmutableList(com.google.common.collect.ImmutableList) QueryId(io.prestosql.spi.QueryId) Driver(io.prestosql.operator.Driver) Page(io.prestosql.spi.Page) QueryContext(io.prestosql.memory.QueryContext) TaskStateMachine(io.prestosql.execution.TaskStateMachine) PageConsumerOperator(io.prestosql.testing.PageConsumerOperator) DataSize(io.airlift.units.DataSize) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) MemoryPoolId(io.prestosql.spi.memory.MemoryPoolId) MemoryPool(io.prestosql.memory.MemoryPool)

Aggregations

Driver (io.prestosql.operator.Driver)14 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)10 DriverFactory (io.prestosql.operator.DriverFactory)7 ImmutableList (com.google.common.collect.ImmutableList)5 DriverContext (io.prestosql.operator.DriverContext)5 PagesIndex (io.prestosql.operator.PagesIndex)5 ScheduledSplit (io.prestosql.execution.ScheduledSplit)4 TaskSource (io.prestosql.execution.TaskSource)4 Split (io.prestosql.metadata.Split)4 Type (io.prestosql.spi.type.Type)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Session (io.prestosql.Session)3 HashBuilderOperatorFactory (io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory)3 OperatorFactory (io.prestosql.operator.OperatorFactory)3 PartitionedLookupSourceFactory (io.prestosql.operator.PartitionedLookupSourceFactory)3 TaskContext (io.prestosql.operator.TaskContext)3 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Duration (io.airlift.units.Duration)2