DefaultIndexer extends Indexer { @Override public void addIndexMutations(ColumnMutationCache mutationCache) throws IOException { for (Entry<byte[], Map<byte[], RowMutation>> tableMutation : mutationCache.getMutations()) { byte[] tableName = tableMutation.getKey(); for (Entry<byte[], RowMutation> rowMutation : tableMutation.getValue().entrySet()) { byte[] row = rowMutation.getKey(); for (ColumnMutation columnMuation : rowMutation.getValue().mutationList()) { if (columnMuation.getType().equals(Type.Put)) { IndexColumn indexColumn = new IndexColumn(tableName, columnMuation.getFamily(), columnMuation.getQualifier()); if (columnIndexes.containsKey(indexColumn)) { String indexTableName = columnIndexes.get(indexColumn); KeyValue indexKv = constructIndexKv(row, columnMuation.getValue()); mutationCache.addMutation(Bytes.toBytes(indexTableName), indexKv); } } } } } } DefaultIndexer(Configuration conf); Map<IndexColumn, String> getColumnIndexes(); @Override IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction); @Override void addIndexMutations(ColumnMutationCache mutationCache);  }
@Test public void testAddIndexMutations() throws IOException { ColumnMutationCache mutationCache = new ColumnMutationCache(); mutationCache.addMutation(TABLENAME, KEYVALUE); mutationCache.addMutation(MAIN_TABLE, new KeyValue(ROW, ANOTHER_FAMILY, INDEX_QUALIFIER, Long.MAX_VALUE, Type.Put, VALUE)); mutationCache.addMutation(MAIN_TABLE, new KeyValue(ROW, INDEX_FAMILY, ANOTHER_QUALIFIER, Long.MAX_VALUE, Type.Put, VALUE)); mutationCache.addMutation(MAIN_TABLE, new KeyValue(ROW, INDEX_FAMILY, INDEX_QUALIFIER, Long.MAX_VALUE, Type.DeleteColumn, VALUE)); DefaultIndexer indexer = new DefaultIndexer(conf); indexer.addIndexMutations(mutationCache); Assert.assertEquals(4, mutationCache.size()); mutationCache.addMutation(MAIN_TABLE, new KeyValue(ROW, INDEX_FAMILY, INDEX_QUALIFIER, Long.MAX_VALUE, Type.Put, VALUE)); indexer.addIndexMutations(mutationCache); Assert.assertEquals(5, mutationCache.size()); ColumnCoordinate columnCoordinate = new ColumnCoordinate(INDEX_TABLE, VALUE, IndexMasterObserver.THEMIS_SECONDARY_INDEX_TABLE_FAMILY_BYTES, ROW); Pair<Type, byte[]> typeAndValue = mutationCache.getMutation(columnCoordinate); Assert.assertNotNull(typeAndValue); Assert.assertEquals(Type.Put, typeAndValue.getFirst()); Assert.assertArrayEquals(HConstants.EMPTY_BYTE_ARRAY, typeAndValue.getSecond()); }