Search in sources :

Example 1 with OutputBuffer

use of io.prestosql.execution.buffer.OutputBuffer in project hetu-core by openlookeng.

the class TestTaskOutputOperatorFactory method testDuplicate.

@Test
public void testDuplicate() {
    OutputBuffer outputBuffer = mock(OutputBuffer.class);
    TaskOutputOperatorFactory factory1 = new TaskOutputOperatorFactory(1, new PlanNodeId("planNodeId"), outputBuffer, a -> a);
    OperatorFactory factory2 = factory1.duplicate();
    OperatorFactory factory3 = factory1.duplicate();
    OperatorFactory factory4 = factory2.duplicate();
    factory1.noMoreOperators();
    factory3.noMoreOperators();
    factory4.noMoreOperators();
    verify(outputBuffer, never()).setNoMoreInputChannels();
    factory2.noMoreOperators();
    verify(outputBuffer).setNoMoreInputChannels();
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TaskOutputOperatorFactory(io.prestosql.operator.TaskOutputOperator.TaskOutputOperatorFactory) TaskOutputOperatorFactory(io.prestosql.operator.TaskOutputOperator.TaskOutputOperatorFactory) OutputBuffer(io.prestosql.execution.buffer.OutputBuffer) Test(org.testng.annotations.Test)

Example 2 with OutputBuffer

use of io.prestosql.execution.buffer.OutputBuffer in project hetu-core by openlookeng.

the class TestPartitionedOutputOperatorFactory method testDuplicate.

@Test
public void testDuplicate() {
    OutputBuffer outputBuffer = mock(OutputBuffer.class);
    PartitionedOutputOperatorFactory factory1 = new PartitionedOutputOperatorFactory(1, new PlanNodeId("planNodeId"), Collections.emptyList(), a -> a, mock(PartitionFunction.class), Collections.emptyList(), Collections.emptyList(), false, OptionalInt.empty(), outputBuffer, DataSize.succinctBytes(1));
    OperatorFactory factory2 = factory1.duplicate();
    OperatorFactory factory3 = factory1.duplicate();
    OperatorFactory factory4 = factory2.duplicate();
    factory1.noMoreOperators();
    factory3.noMoreOperators();
    factory4.noMoreOperators();
    verify(outputBuffer, never()).setNoMoreInputChannels();
    factory2.noMoreOperators();
    verify(outputBuffer).setNoMoreInputChannels();
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PartitionedOutputOperatorFactory(io.prestosql.operator.PartitionedOutputOperator.PartitionedOutputOperatorFactory) OutputBuffer(io.prestosql.execution.buffer.OutputBuffer) PartitionedOutputOperatorFactory(io.prestosql.operator.PartitionedOutputOperator.PartitionedOutputOperatorFactory) Test(org.testng.annotations.Test)

Example 3 with OutputBuffer

use of io.prestosql.execution.buffer.OutputBuffer in project hetu-core by openlookeng.

the class TaskOutputOperator method addInput.

@Override
public void addInput(Page page) {
    requireNonNull(page, "page is null");
    Page inputPage = page;
    if (snapshotState != null) {
        if (snapshotState.processPage(inputPage)) {
            inputPage = snapshotState.nextMarker();
        }
    }
    if (inputPage.getPositionCount() == 0) {
        return;
    }
    if (!(inputPage instanceof MarkerPage)) {
        inputPage = pagePreprocessor.apply(inputPage);
    } else if (isStage0) {
        // Do not add marker to final output.
        return;
    }
    List<SerializedPage> serializedPages = splitPage(inputPage, DEFAULT_MAX_PAGE_SIZE_IN_BYTES).stream().map(p -> serde.serialize(p)).collect(toImmutableList());
    if (inputPage instanceof MarkerPage) {
        // The result is that for buffer #2, it receives marker 2 before marker 1.
        synchronized (outputBuffer) {
            outputBuffer.enqueue(serializedPages, id);
        }
    } else {
        outputBuffer.enqueue(serializedPages, id);
    }
    operatorContext.recordOutput(inputPage.getSizeInBytes(), inputPage.getPositionCount());
}
Also used : OutputBuffer(io.prestosql.execution.buffer.OutputBuffer) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SingleInputSnapshotState(io.prestosql.snapshot.SingleInputSnapshotState) Page(io.prestosql.spi.Page) RestorableConfig(io.prestosql.spi.snapshot.RestorableConfig) Function(java.util.function.Function) Serializable(java.io.Serializable) Preconditions.checkState(com.google.common.base.Preconditions.checkState) PageSplitterUtil.splitPage(io.prestosql.execution.buffer.PageSplitterUtil.splitPage) List(java.util.List) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PagesSerde(io.hetu.core.transport.execution.buffer.PagesSerde) Objects.requireNonNull(java.util.Objects.requireNonNull) Type(io.prestosql.spi.type.Type) BlockEncodingSerdeProvider(io.prestosql.spi.snapshot.BlockEncodingSerdeProvider) DEFAULT_MAX_PAGE_SIZE_IN_BYTES(io.prestosql.spi.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) Page(io.prestosql.spi.Page) PageSplitterUtil.splitPage(io.prestosql.execution.buffer.PageSplitterUtil.splitPage) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage)

Example 4 with OutputBuffer

use of io.prestosql.execution.buffer.OutputBuffer in project boostkit-bigdata by kunpengcompute.

the class OmniLocalQueryRunner method createDriversWithPlanOnly.

private void createDriversWithPlanOnly(Session session, Plan plan, OutputFactory outputFactory, TaskContext taskContext) {
    if (printPlan) {
        System.out.println(PlanPrinter.textLogicalPlan(plan.getRoot(), plan.getTypes(), metadata, plan.getStatsAndCosts(), session, 0, false));
    }
    SubPlan subplan = planFragmenter.createSubPlans(session, plan, true, WarningCollector.NOOP);
    if (!subplan.getChildren().isEmpty()) {
        throw new AssertionError("Expected subplan to have no children");
    }
    NodeInfo nodeInfo = new NodeInfo("test");
    FileSystemClientManager fileSystemClientManager = new FileSystemClientManager();
    SeedStoreManager seedStoreManager = new SeedStoreManager(fileSystemClientManager);
    StateStoreProvider stateStoreProvider = new LocalStateStoreProvider(seedStoreManager);
    LocalExecutionPlanner localExecutionPlanner = new LocalExecutionPlanner(metadata, new TypeAnalyzer(sqlParser, metadata), Optional.empty(), pageSourceManager, indexManager, nodePartitioningManager, pageSinkManager, null, expressionCompiler, pageFunctionCompiler, joinFilterFunctionCompiler, new IndexJoinLookupStats(), this.taskManagerConfig, spillerFactory, singleStreamSpillerFactory, partitioningSpillerFactory, new PagesIndex.TestingFactory(false), joinCompiler, new LookupJoinOperators(), new OrderingCompiler(), nodeInfo, stateStoreProvider, new StateStoreListenerManager(stateStoreProvider), new DynamicFilterCacheManager(), heuristicIndexerManager, cubeManager);
    OmniLocalExecutionPlanner omniLocalExecutionPlanner = new OmniLocalExecutionPlanner(localExecutionPlanner);
    ScheduledExecutorService taskNotificationExecutor = newScheduledThreadPool(10, threadsNamed("task-notification-%s"));
    OutputBuffer outputBuffer = new PartitionedOutputBuffer(new StateMachine<>("bufferState", taskNotificationExecutor, OPEN, TERMINAL_BUFFER_STATES), createInitialEmptyOutputBuffers(PARTITIONED).withBuffer(new OutputBuffers.OutputBufferId(0), 0).withNoMoreBufferIds(), new DataSize(1, MEGABYTE), () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), taskNotificationExecutor);
    StageExecutionDescriptor stageExecutionDescriptor = subplan.getFragment().getStageExecutionDescriptor();
    omniLocalExecutionPlanner.plan(taskContext, subplan.getFragment().getRoot(), plan.getTypes(), new PartitioningScheme(Partitioning.create(FIXED_HASH_DISTRIBUTION, ImmutableList.of()), subplan.getFragment().getRoot().getOutputSymbols(), Optional.empty(), false, Optional.of(new int[] { 1 })), stageExecutionDescriptor, subplan.getFragment().getPartitionedSources(), outputBuffer, Optional.empty(), Optional.empty(), null);
}
Also used : StateStoreListenerManager(io.prestosql.statestore.listener.StateStoreListenerManager) PagesIndex(io.prestosql.operator.PagesIndex) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) OutputBuffer(io.prestosql.execution.buffer.OutputBuffer) PartitionedOutputBuffer(io.prestosql.execution.buffer.PartitionedOutputBuffer) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) OutputBuffers.createInitialEmptyOutputBuffers(io.prestosql.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers) OutputBuffers(io.prestosql.execution.buffer.OutputBuffers) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) DataSize(io.airlift.units.DataSize) OrderingCompiler(io.prestosql.sql.gen.OrderingCompiler) LookupJoinOperators(io.prestosql.operator.LookupJoinOperators) DynamicFilterCacheManager(io.prestosql.dynamicfilter.DynamicFilterCacheManager) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LocalExecutionPlanner(io.prestosql.sql.planner.LocalExecutionPlanner) PartitionedOutputBuffer(io.prestosql.execution.buffer.PartitionedOutputBuffer) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) IndexJoinLookupStats(io.prestosql.operator.index.IndexJoinLookupStats) StageExecutionDescriptor(io.prestosql.operator.StageExecutionDescriptor) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) NodeInfo(io.airlift.node.NodeInfo) SubPlan(io.prestosql.sql.planner.SubPlan)

Aggregations

OutputBuffer (io.prestosql.execution.buffer.OutputBuffer)4 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)3 Test (org.testng.annotations.Test)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 NodeInfo (io.airlift.node.NodeInfo)1 DataSize (io.airlift.units.DataSize)1 PagesSerde (io.hetu.core.transport.execution.buffer.PagesSerde)1 SerializedPage (io.hetu.core.transport.execution.buffer.SerializedPage)1 DynamicFilterCacheManager (io.prestosql.dynamicfilter.DynamicFilterCacheManager)1 OutputBuffers (io.prestosql.execution.buffer.OutputBuffers)1 OutputBuffers.createInitialEmptyOutputBuffers (io.prestosql.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers)1 PageSplitterUtil.splitPage (io.prestosql.execution.buffer.PageSplitterUtil.splitPage)1 PartitionedOutputBuffer (io.prestosql.execution.buffer.PartitionedOutputBuffer)1 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)1 SimpleLocalMemoryContext (io.prestosql.memory.context.SimpleLocalMemoryContext)1 LookupJoinOperators (io.prestosql.operator.LookupJoinOperators)1 PagesIndex (io.prestosql.operator.PagesIndex)1 PartitionedOutputOperatorFactory (io.prestosql.operator.PartitionedOutputOperator.PartitionedOutputOperatorFactory)1