use of io.prestosql.operator.Operator in project boostkit-bigdata by kunpengcompute.
the class OrderByOperatorTest method testProcess.
@Test(dataProvider = "pageProvider")
public void testProcess(int i) {
Operator operator = getOperator();
Page page = getPageForTest(i);
if (page == null) {
assertThrows("page is null", NullPointerException.class, () -> operator.addInput(page));
} else {
operator.addInput(page);
}
assertFalse(operator.isFinished());
operator.finish();
operator.getOutput();
// assertFalse(operator.needsInput());
}
use of io.prestosql.operator.Operator in project boostkit-bigdata by kunpengcompute.
the class FilterAndProjectOmniOperatorTest method testProcess.
@Test(dataProvider = "pageProvider")
public void testProcess(int i) {
Operator operator = getOperator();
Page page = getPageForTest(i);
if (page == null) {
assertThrows("page is null", NullPointerException.class, () -> operator.addInput(page));
} else {
operator.addInput(page);
}
assertFalse(operator.isFinished());
operator.finish();
operator.getOutput();
assertTrue(operator.isFinished());
assertFalse(operator.needsInput());
}
use of io.prestosql.operator.Operator in project boostkit-bigdata by kunpengcompute.
the class WindowOmniOperatorTest method testProcess.
@Test(dataProvider = "pageProvider")
public void testProcess(int i) {
Operator operator = getOperator();
Page page = getPageForTest(i);
if (page == null) {
assertThrows("page is null", NullPointerException.class, () -> operator.addInput(page));
} else {
operator.addInput(page);
}
assertFalse(operator.isFinished());
operator.finish();
do {
operator.getOutput();
} while (!operator.isFinished());
assertNull(operator.getOutput());
assertFalse(operator.needsInput());
}
use of io.prestosql.operator.Operator in project boostkit-bigdata by kunpengcompute.
the class AggregationOmniOperatorTest method testProcess.
@Test(dataProvider = "pageProvider")
public void testProcess(int i) {
Operator operator = getOperator();
Page page = getPageForTest(i);
if (page == null) {
assertThrows("page is null", NullPointerException.class, () -> operator.addInput(null));
} else {
operator.addInput(page);
}
assertFalse(operator.isFinished());
operator.finish();
operator.getOutput();
if (page != null) {
assertTrue(operator.isFinished());
}
assertNull(operator.getOutput());
}
use of io.prestosql.operator.Operator in project hetu-core by openlookeng.
the class TestSpatialJoinOperator method testYield.
@Test
public void testYield() {
// create a filter function that yields for every probe match
// verify we will yield #match times totally
TaskContext taskContext = createTaskContext();
DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
// force a yield for every match
AtomicInteger filterFunctionCalls = new AtomicInteger();
InternalJoinFilterFunction filterFunction = new TestInternalJoinFilterFunction(((leftPosition, leftPage, rightPosition, rightPage) -> {
filterFunctionCalls.incrementAndGet();
driverContext.getYieldSignal().forceYieldForTesting();
return true;
}));
RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").pageBreak().row(POLYGON_B, "B");
PagesSpatialIndexFactory pagesSpatialIndexFactory = buildIndex(driverContext, (build, probe, r) -> build.contains(probe), Optional.empty(), Optional.of(filterFunction), buildPages);
// 10 points in polygon A (x0...x9)
// 10 points in polygons A and B (y0...y9)
// 10 points in polygon B (z0...z9)
// 40 total matches
RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR));
for (int i = 0; i < 10; i++) {
probePages.row(stPoint(1 + 0.1 * i, 1 + 0.1 * i), "x" + i);
}
for (int i = 0; i < 10; i++) {
probePages.row(stPoint(4.5 + 0.01 * i, 4.5 + 0.01 * i), "y" + i);
}
for (int i = 0; i < 10; i++) {
probePages.row(stPoint(6 + 0.1 * i, 6 + 0.1 * i), "z" + i);
}
List<Page> probeInput = probePages.build();
OperatorFactory joinOperatorFactory = new SpatialJoinOperatorFactory(2, new PlanNodeId("test"), INNER, probePages.getTypes(), Ints.asList(1), 0, Optional.empty(), pagesSpatialIndexFactory);
Operator operator = joinOperatorFactory.createOperator(driverContext);
assertTrue(operator.needsInput());
operator.addInput(probeInput.get(0));
operator.finish();
// we will yield 40 times due to filterFunction
for (int i = 0; i < 40; i++) {
driverContext.getYieldSignal().setWithDelay(5 * SECONDS.toNanos(1), driverContext.getYieldExecutor());
assertNull(operator.getOutput());
assertEquals(filterFunctionCalls.get(), i + 1, "Expected join to stop processing (yield) after calling filter function once");
driverContext.getYieldSignal().reset();
}
// delayed yield is not going to prevent operator from producing a page now (yield won't be forced because filter function won't be called anymore)
driverContext.getYieldSignal().setWithDelay(5 * SECONDS.toNanos(1), driverContext.getYieldExecutor());
Page output = operator.getOutput();
assertNotNull(output);
// make sure we have 40 matches
assertEquals(output.getPositionCount(), 40);
}
Aggregations