Source:
<code>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(); <START> assertBetweenInclusive(memoryUsage, 360000L, 469999L); <END> } 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); }</code><technical_language>Instead of widening range include aria non-aria cases, consider setting range based aria is enabled not: if (isAriaScanEnabled(driverContext.getSession())) { assertBetweenInclusive(memoryUsage, 360000L, 369999L); } else { assertBetweenInclusive(memoryUsage, 460000L, 469999L); }</technical_language>

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 (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); }