@Override public void addInput(Page page) { requireNonNull(page, "page is null"); checkState(needsInput(), "Operator does not need input"); Block[] blocks = new Block[columnChannels.size()]; for (int outputChannel = 0; outputChannel < columnChannels.size(); outputChannel++) { blocks[outputChannel] = page.getBlock(columnChannels.get(outputChannel)); } OperationTimer timer = new OperationTimer(statisticsCpuTimerEnabled); statisticAggregationOperator.addInput(page); timer.end(statisticsTiming); ListenableFuture<?> blockedOnAggregation = statisticAggregationOperator.isBlocked(); CompletableFuture<?> future = pageSink.appendPage(new Page(blocks)); updateMemoryUsage(); ListenableFuture<?> blockedOnWrite = toListenableFuture(future); blocked = allAsList(blockedOnAggregation, blockedOnWrite); rowCount += page.getPositionCount(); updateWrittenBytes(); }
@Override public void addInput(Page page) { requireNonNull(page, "page is null"); checkState(state == State.RUNNING, "Operator is %s", state); Block rowCountBlock = page.getBlock(ROW_COUNT_CHANNEL); Block fragmentBlock = page.getBlock(FRAGMENT_CHANNEL); for (int position = 0; position < page.getPositionCount(); position++) { if (!rowCountBlock.isNull(position)) { rowCount += BIGINT.getLong(rowCountBlock, position); } if (!fragmentBlock.isNull(position)) { fragmentBuilder.add(VARBINARY.getSlice(fragmentBlock, position)); } } extractStatisticsRows(page).ifPresent(statisticsPage -> { OperationTimer timer = new OperationTimer(statisticsCpuTimerEnabled); statisticsAggregationOperator.addInput(statisticsPage); timer.end(statisticsTiming); }); }
@Test(expectedExceptions = IllegalStateException.class) public void addInputFailsOnBlockedOperator() { Operator operator = createTableWriterOperator(new BlockingPageSink()); operator.addInput(rowPagesBuilder(BIGINT).row(42).build().get(0)); assertFalse(operator.isBlocked().isDone()); assertFalse(operator.needsInput()); operator.addInput(rowPagesBuilder(BIGINT).row(42).build().get(0)); }
next.addInput(page); next.getOperatorContext().recordAddInput(operationTimer, page); movedPage = true;
@Test public void testExceedMemoryLimit() throws Exception { List<Page> input = rowPagesBuilder(BIGINT) .row(1L) .build(); DriverContext smallDiverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION, new DataSize(1, BYTE)) .addPipelineContext(0, true, true, false) .addDriverContext(); TopNOperatorFactory operatorFactory = new TopNOperatorFactory( 0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST)); try (Operator operator = operatorFactory.createOperator(smallDiverContext)) { operator.addInput(input.get(0)); fail("must fail because of exceeding local memory limit"); } catch (ExceededMemoryLimitException ignore) { } } }
private static Page getAtMostOnePage(Operator operator, Page sourcePage) { // add our input page if needed if (operator.needsInput()) { operator.addInput(sourcePage); } // try to get the output page Page result = operator.getOutput(); // tell operator to finish operator.finish(); // try to get output until the operator is finished while (!operator.isFinished()) { // operator should never block assertTrue(operator.isBlocked().isDone()); Page output = operator.getOutput(); if (output != null) { assertNull(result); result = output; } } return result; }
operator.addInput(input);
operator.addInput(pages.get(0)); Page outputPage = operator.getOutput(); assertNull(outputPage);
operator.addInput(pages.get(0)); Page outputPage = operator.getOutput(); assertNull(outputPage);
operator.addInput(probeInput.get(0)); operator.finish();
Operator operator = joinOperatorFactory.createOperator(driverContext); assertTrue(operator.needsInput()); operator.addInput(probeInput.get(0)); operator.finish();
operator.addInput(page);
@Test(expectedExceptions = IllegalStateException.class) public void addInputFailsOnBlockedOperator() throws Exception { Operator operator = createTableWriterOperator(new BlockingPageSink()); operator.addInput(rowPagesBuilder(BIGINT).row(42).build().get(0)); assertEquals(operator.isBlocked().isDone(), false); assertEquals(operator.needsInput(), false); operator.addInput(rowPagesBuilder(BIGINT).row(42).build().get(0)); }
private static Page getAtMostOnePage(Operator operator, Page sourcePage) { // add our input page if needed if (operator.needsInput()) { operator.addInput(sourcePage); } // try to get the output page Page result = operator.getOutput(); // tell operator to finish operator.finish(); // try to get output until the operator is finished while (!operator.isFinished()) { // operator should never block assertTrue(operator.isBlocked().isDone()); Page output = operator.getOutput(); if (output != null) { assertNull(result); result = output; } } return result; }
next.addInput(page); next.getOperatorContext().recordAddInput(page); movedPage = true;
operator.addInput(probeInput.get(0)); operator.finish();