Search in sources :

Example 6 with SourceOperator

use of com.facebook.presto.operator.SourceOperator in project presto by prestodb.

the class TestOrcBatchPageSourceMemoryTracking method testScanFilterAndProjectOperator.

@Test
public void testScanFilterAndProjectOperator() {
    // Numbers used in assertions in this test may change when implementation is modified,
    // feel free to change them if they break in the future
    DriverContext driverContext = testPreparer.newDriverContext();
    SourceOperator operator = testPreparer.newScanFilterAndProjectOperator(driverContext);
    assertEquals(driverContext.getSystemMemoryUsage(), 0);
    int totalRows = 0;
    while (totalRows < NUM_ROWS) {
        assertFalse(operator.isFinished());
        Page page = operator.getOutput();
        assertNotNull(page);
        assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 90_000L, 619999L);
        totalRows += page.getPositionCount();
    }
    // done... in the current implementation finish is not set until output returns a null page
    assertNull(operator.getOutput());
    assertTrue(operator.isFinished());
    assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 0L, 500L);
}
Also used : DriverContext(com.facebook.presto.operator.DriverContext) SourceOperator(com.facebook.presto.operator.SourceOperator) Page(com.facebook.presto.common.Page) Test(org.testng.annotations.Test)

Example 7 with SourceOperator

use of com.facebook.presto.operator.SourceOperator in project presto by prestodb.

the class TestOrcBatchPageSourceMemoryTracking method testTableScanOperator.

@Test
public void testTableScanOperator() {
    // Numbers used in assertions in this test may change when implementation is modified,
    // feel free to change them if they break in the future
    DriverContext driverContext = testPreparer.newDriverContext();
    SourceOperator operator = testPreparer.newTableScanOperator(driverContext);
    assertEquals(driverContext.getSystemMemoryUsage(), 0);
    int totalRows = 0;
    while (totalRows < 20000) {
        assertFalse(operator.isFinished());
        Page page = operator.getOutput();
        assertNotNull(page);
        page.getBlock(1);
        assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 390000L, 619999L);
        totalRows += page.getPositionCount();
    }
    while (totalRows < 40000) {
        assertFalse(operator.isFinished());
        Page page = operator.getOutput();
        assertNotNull(page);
        page.getBlock(1);
        assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 390000L, 619999L);
        totalRows += page.getPositionCount();
    }
    while (totalRows < NUM_ROWS) {
        assertFalse(operator.isFinished());
        Page page = operator.getOutput();
        assertNotNull(page);
        page.getBlock(1);
        assertBetweenInclusive(driverContext.getSystemMemoryUsage(), 430000L, 459999L);
        totalRows += page.getPositionCount();
    }
    assertFalse(operator.isFinished());
    assertNull(operator.getOutput());
    assertTrue(operator.isFinished());
    assertEquals(driverContext.getSystemMemoryUsage(), 0);
}
Also used : DriverContext(com.facebook.presto.operator.DriverContext) SourceOperator(com.facebook.presto.operator.SourceOperator) Page(com.facebook.presto.common.Page) Test(org.testng.annotations.Test)

Aggregations

SourceOperator (com.facebook.presto.operator.SourceOperator)7 DriverContext (com.facebook.presto.operator.DriverContext)4 Test (org.testng.annotations.Test)4 Page (com.facebook.presto.common.Page)2 Page (com.facebook.presto.spi.Page)2 PageBuilder (com.facebook.presto.spi.PageBuilder)1