### Question:
MemoryManager { synchronized void addedRow() throws IOException { if (++rowsAddedSinceCheck >= ROWS_BETWEEN_CHECKS) { notifyWriters(); } } MemoryManager(Configuration conf); synchronized boolean isLowMemoryMode();  }### Answer:
@Test public void testLowMemoryModeBidirectional() throws Exception { Configuration conf = new Configuration(); MemoryManagerForTest mgr = new MemoryManagerForTest(conf); MemoryManager.Callback[] calls = new MemoryManager.Callback[8]; initializeLowMemoryModeTest(mgr, calls); for (int i = 0; i < calls.length / 2; i++) { mgr.incrementFlushCount(new Path(Integer.toString(i * 2)), 2); } for (int i = 0; i < 10000; i++) { mgr.addedRow(); } for(int i = 0; i < calls.length; i++) { if (i % 2 == 0) { Assert.assertEquals("Popular writers not getting more memory", 1.75, mgr.getAllocationMultiplierForPath(new Path(Integer.toString(i)))); } else { Assert.assertEquals("Unpopular writers hanging onto memory", 0.25, mgr.getAllocationMultiplierForPath(new Path(Integer.toString(i)))); } } for (int i = 0; i < calls.length / 2; i++) { mgr.incrementFlushCount(new Path(Integer.toString((i * 2) + 1)), 2); } for (int i = 0; i < 5000; i++) { mgr.addedRow(); } for(int i = 0; i < calls.length; i++) { if (i % 2 == 0) { Assert.assertEquals("Popular writers not getting more memory", 0.875, mgr.getAllocationMultiplierForPath(new Path(Integer.toString(i)))); } else { Assert.assertEquals("Unpopular writers hanging onto memory", 1.125, mgr.getAllocationMultiplierForPath(new Path(Integer.toString(i)))); } } }