Source:
public void testTableScanOperator() { DriverContext driverContext = testPreparer.newDriverContext(); SourceOperator operator = testPreparer.newTableScanOperator(driverContext); assertEquals(driverContext.getSystemMemoryUsage(), 0); long memoryUsage = -1; int totalRows = 0; while (totalRows < 20000) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); assertBetweenInclusive(memoryUsage, 460000L, 469999L); } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } memoryUsage = -1; while (totalRows < 40000) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); if (SystemSessionProperties.isAriaScanEnabled(driverContext.getSession())) { assertBetweenInclusive(memoryUsage, 360000L, 369999L); } else { assertBetweenInclusive(memoryUsage, 460000L, 469999L); } } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } memoryUsage = -1; while (totalRows < NUM_ROWS) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); assertBetweenInclusive(memoryUsage, 360000L, 369999L); } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } assertFalse(operator.isFinished()); assertNull(operator.getOutput()); assertTrue(operator.isFinished()); assertEquals(driverContext.getSystemMemoryUsage(), 0); }

Target:
public void testTableScanOperator() { DriverContext driverContext = testPreparer.newDriverContext(); SourceOperator operator = testPreparer.newTableScanOperator(driverContext); assertEquals(driverContext.getSystemMemoryUsage(), 0); long memoryUsage = -1; int totalRows = 0; while (totalRows < 20000) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); assertBetweenInclusive(memoryUsage, 460000L, 469999L); } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } memoryUsage = -1; while (totalRows < 40000) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); if (isAriaScanEnabled(driverContext.getSession().toConnectorSession())) { assertBetweenInclusive(memoryUsage, 360000L, 369999L); } else { assertBetweenInclusive(memoryUsage, 460000L, 469999L); } } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } memoryUsage = -1; while (totalRows < NUM_ROWS) { assertFalse(operator.isFinished()); Page page = operator.getOutput(); assertNotNull(page); page.getBlock(0); if (memoryUsage == -1) { memoryUsage = driverContext.getSystemMemoryUsage(); assertBetweenInclusive(memoryUsage, 360000L, 369999L); } else { assertEquals(driverContext.getSystemMemoryUsage(), memoryUsage); } totalRows += page.getPositionCount(); } assertFalse(operator.isFinished()); assertNull(operator.getOutput()); assertTrue(operator.isFinished()); assertEquals(driverContext.getSystemMemoryUsage(), 0); }