### Question:
IndexMapReduceUtil { public static List<Delete> getIndexDelete(Delete userDelete, Configuration conf) throws IOException { String tableName = conf.get(TableInputFormat.INPUT_TABLE); IndexedHTableDescriptor tableDescriptor = getTableDescriptor(tableName, conf); List<Delete> indexDeletes = new ArrayList<Delete>(); if (tableDescriptor != null) { List<IndexSpecification> indices = tableDescriptor.getIndices(); for (IndexSpecification index : indices) { byte[] startkey = getStartKey(conf, tableName, userDelete.getRow()); Delete indexDelete = IndexUtils.prepareIndexDelete(userDelete, index, startkey); if (indexDelete != null) { indexDeletes.add(indexDelete); } } } return indexDeletes; }  static IndexedHTableDescriptor getTableDescriptor(String tableName, Configuration conf); static boolean isIndexedTable(String tableName, Configuration conf); static boolean isIndexedTable(Configuration conf); static List<Put> getIndexPut(Put userPut, Configuration conf); static List<Delete> getIndexDelete(Delete userDelete, Configuration conf); static byte[] getStartKey(Configuration conf, String tableName, byte[] row); static final String INDEX_DATA_DIR; static final String INDEX_IS_INDEXED_TABLE; }### Answer:
@Test(timeout = 180000) public void testShouldFormIndexPutsAndIndexDeletes() throws Exception { tableName = "testShouldFormIndexPutsAndIndexDeletes"; IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(tableName); HColumnDescriptor hcd = new HColumnDescriptor("col"); IndexSpecification iSpec = new IndexSpecification("ScanIndexf"); iSpec.addIndexColumn(hcd, "q1", ValueType.String, 10); iSpec.addIndexColumn(hcd, "q2", ValueType.String, 10); ihtd.addFamily(hcd); ihtd.addIndex(iSpec); admin.getConfiguration().set(TableInputFormat.INPUT_TABLE, tableName); admin.createTable(ihtd); HTable mainTable = new HTable(conf, Bytes.toBytes(tableName)); Put put = new Put(Bytes.toBytes("r1")); put.add(hcd.getName(), Bytes.toBytes("q1"), Bytes.toBytes("v1")); mainTable.put(put); put = new Put(Bytes.toBytes("r2")); put.add(hcd.getName(), Bytes.toBytes("q1"), Bytes.toBytes("v1")); mainTable.put(put); put = new Put(Bytes.toBytes("r3")); put.add(hcd.getName(), Bytes.toBytes("q1"), Bytes.toBytes("v1")); put.add(hcd.getName(), Bytes.toBytes("q2"), Bytes.toBytes("v2")); mainTable.put(put); put = new Put(Bytes.toBytes("r4")); put.add(hcd.getName(), Bytes.toBytes("q1"), Bytes.toBytes("v1")); mainTable.put(put); put = new Put(Bytes.toBytes("r5")); put.add(hcd.getName(), Bytes.toBytes("q1"), Bytes.toBytes("v1")); mainTable.put(put); mainTable.flushCommits(); admin.flush(tableName); Delete del = new Delete(Bytes.toBytes("r3")); del.deleteFamily(hcd.getName()); mainTable.delete(del); List<Delete> indexDelete = IndexMapReduceUtil.getIndexDelete(del, admin.getConfiguration()); assertTrue(indexDelete.size() == 0); admin.flush(tableName); del = new Delete(Bytes.toBytes("r5")); del.deleteColumns(hcd.getName(), Bytes.toBytes("q1")); mainTable.delete(del); indexDelete = IndexMapReduceUtil.getIndexDelete(del, admin.getConfiguration()); Map<byte[], List<KeyValue>> familyMap = ((Delete) indexDelete.get(0)).getFamilyMap(); Set<Entry<byte[], List<KeyValue>>> entrySet = familyMap.entrySet(); for (Entry<byte[], List<KeyValue>> entry : entrySet) { List<KeyValue> value = entry.getValue(); assertTrue(!value.get(0).isDeleteFamily()); } }