### Question:
IndexUpdateManager { public void addIndexUpdate(byte[] tableName, Mutation m) { ImmutableBytesPtr key = new ImmutableBytesPtr(tableName); Collection<Mutation> updates = map.get(key); if (updates == null) { updates = new TreeSet<Mutation>(COMPARATOR); map.put(key, updates); } if (indexMetaData.getReplayWrite() != null) { updates.add(m); } else { fixUpCurrentUpdates(updates, m); } } IndexUpdateManager(IndexMetaData indexMetaData); void addIndexUpdate(byte[] tableName, Mutation m); List<Pair<Mutation, byte[]>> toMap(); void addAll(Collection<Pair<Mutation, String>> updates); @Override String toString(); public Comparator<Mutation> COMPARATOR; }### Answer:
@Test public void testCancelingUpdates() throws Exception { IndexUpdateManager manager = new IndexUpdateManager(mockIndexMetaData); long ts1 = 10, ts2 = 11; Delete d = new Delete(row, ts1); Put p = new Put(row, ts2); manager.addIndexUpdate(table, d); manager.addIndexUpdate(table, p); List<Mutation> pending = new ArrayList<Mutation>(); pending.add(p); pending.add(d); validate(manager, pending); Delete d2 = new Delete(row, ts2); manager.addIndexUpdate(table, d2); pending.add(d); validate(manager, pending); Delete d3 = new Delete(row, ts2); manager.addIndexUpdate(table, d3); pending.add(d); validate(manager, pending); manager = new IndexUpdateManager(mockIndexMetaData); manager.addIndexUpdate(table, d2); manager.addIndexUpdate(table, p); validate(manager, Collections.<Mutation> emptyList()); manager = new IndexUpdateManager(mockIndexMetaData); manager.addIndexUpdate(table, p); byte[] row1 = Bytes.toBytes("row1"); Put p1 = new Put(row1, ts1); manager.addIndexUpdate(table, p1); Delete d4 = new Delete(row1, ts1); manager.addIndexUpdate(table, d4); pending.clear(); pending.add(p); validate(manager, pending); }