@Override public Page getOutput() { if (source == null) { return null; } return source.getOutput(); }
private static void waitForFinished(Operator operator) throws InterruptedException { // wait for finished or until 10 seconds has passed long endTime = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); while (System.nanoTime() - endTime < 0) { assertEquals(operator.needsInput(), false); assertNull(operator.getOutput()); if (operator.isFinished()) { break; } Thread.sleep(10); } // verify final state assertEquals(operator.isFinished(), true); assertEquals(operator.needsInput(), false); assertNull(operator.getOutput()); assertEquals(operator.getOperatorContext().getOperatorStats().getSystemMemoryReservation().toBytes(), 0); } }
private static List<Page> pullAvailablePages(Operator operator) throws InterruptedException { long endTime = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); List<Page> outputPages = new ArrayList<>(); assertOperatorIsUnblocked(operator); while (!operator.isFinished() && System.nanoTime() - endTime < 0) { assertFalse(operator.needsInput()); Page outputPage = operator.getOutput(); if (outputPage != null) { outputPages.add(outputPage); } else { Thread.sleep(10); } } // verify state assertFalse(operator.needsInput(), "Operator still wants input"); assertTrue(operator.isFinished(), "Expected operator to be finished"); return outputPages; } }
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; }
Page aggregationOutput = statisticAggregationOperator.getOutput(); timer.end(statisticsTiming);
Page page = current.getOutput(); current.getOperatorContext().recordGetOutput(operationTimer, page);
Page page = statisticsAggregationOperator.getOutput(); timer.end(statisticsTiming);
@Test public void testLimitZero() throws Exception { List<Page> input = rowPagesBuilder(BIGINT).row(1L).build(); TopNOperatorFactory factory = new TopNOperatorFactory( 0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 0, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST)); try (Operator operator = factory.createOperator(driverContext)) { assertEquals(operator.isFinished(), true); assertEquals(operator.needsInput(), false); assertEquals(operator.getOutput(), null); } }
Page outputPage = operator.getOutput(); assertNull(outputPage);
Page outputPage = operator.getOutput(); assertNull(outputPage);
driverContext.getYieldSignal().setWithDelay(5 * SECONDS.toNanos(1), driverContext.getYieldExecutor()); filterFunctionCalls.set(0); assertNull(operator.getOutput()); assertEquals(filterFunctionCalls.get(), 1, "Expected join to stop processing (yield) after calling filter function once"); driverContext.getYieldSignal().reset(); output = operator.getOutput();
@Override public Page getOutput() { if (source == null) { return null; } return source.getOutput(); }
public static List<Page> toPages(Operator operator, List<Page> input) { // verify initial state assertEquals(operator.isFinished(), false); assertEquals(operator.needsInput(), true); assertEquals(operator.getOutput(), null); return toPages(operator, input.iterator()); }
private static void addRemainingOutputPages(Operator operator, ImmutableList.Builder<Page> outputPages) { // pull remaining output pages while (!operator.isFinished()) { // at this point the operator should not need more input assertEquals(operator.needsInput(), false); Page outputPage = operator.getOutput(); if (outputPage != null) { outputPages.add(outputPage); } } // verify final state assertEquals(operator.isFinished(), true); assertEquals(operator.needsInput(), false); assertEquals(operator.getOutput(), null); }
private void waitForFinished(Operator operator) throws InterruptedException { // wait for finished or until 10 seconds has passed long endTime = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); while (System.nanoTime() < endTime) { assertEquals(operator.needsInput(), false); assertNull(operator.getOutput()); if (operator.isFinished()) { break; } Thread.sleep(10); } // verify final state assertEquals(operator.isFinished(), true); assertEquals(operator.needsInput(), false); assertNull(operator.getOutput()); assertEquals(operator.getOperatorContext().getOperatorStats().getSystemMemoryReservation().toBytes(), 0); }
@Test public void testLimitZero() throws Exception { List<Page> input = rowPagesBuilder(BIGINT).row(1).build(); TopNOperatorFactory factory = new TopNOperatorFactory( 0, new PlanNodeId("test"), ImmutableList.of(BIGINT), 0, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST), false); Operator operator = factory.createOperator(driverContext); MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).build(); // assertOperatorEquals assumes operators do not start in finished state assertEquals(operator.isFinished(), true); assertEquals(operator.needsInput(), false); assertEquals(operator.getOutput(), null); List<Page> pages = OperatorAssertion.toPages(operator, input.iterator()); MaterializedResult actual = OperatorAssertion.toMaterializedResult(operator.getOperatorContext().getSession(), operator.getTypes(), pages); assertEquals(actual, expected); }