@Test public void testRebuildMultipleVersionRow() throws IOException { Mockito.when(mockIndexMetaData.getReplayWrite()).thenReturn(ReplayWrite.INDEX_ONLY); Cell currentCell1 = CellUtil.createCell(ROW, FAM, INDEXED_QUALIFIER, 1, PUT_TYPE, VALUE_1); Cell currentCell2 = CellUtil.createCell(ROW, FAM, INDEXED_QUALIFIER, 2, PUT_TYPE, VALUE_2); Cell currentCell3 = CellUtil.createCell(ROW, FAM, INDEXED_QUALIFIER, 3, PUT_TYPE, VALUE_3); Cell currentCell4 = CellUtil.createCell(ROW, FAM, INDEXED_QUALIFIER, 4, PUT_TYPE, VALUE_4); setCurrentRowState(Arrays.asList(currentCell4, currentCell3, currentCell2, currentCell1)); MultiMutation mutation = new MultiMutation(new ImmutableBytesPtr(ROW)); Put put = new Put(ROW); put.addImmutable(FAM, INDEXED_QUALIFIER, 4, VALUE_4); mutation.addAll(put); put = new Put(ROW); put.addImmutable(FAM, INDEXED_QUALIFIER, 3, VALUE_3); mutation.addAll(put); put = new Put(ROW); put.addImmutable(FAM, INDEXED_QUALIFIER, 2, VALUE_2); mutation.addAll(put); Collection<Pair<Mutation, byte[]>> indexUpdates = Lists.newArrayList(); for (Mutation m : IndexManagementUtil.flattenMutationsByTimestamp(Collections.singletonList(mutation))) { indexUpdates.addAll(indexBuilder.getIndexUpdate(m, mockIndexMetaData)); } assertEquals(6, indexUpdates.size()); assertContains(indexUpdates, 2, ROW, KeyValue.Type.DeleteFamily, FAM, new byte[0] , 2); assertContains(indexUpdates, ColumnTracker.NO_NEWER_PRIMARY_TABLE_ENTRY_TIMESTAMP, ROW, KeyValue.Type.Put, FAM, QueryConstants.EMPTY_COLUMN_BYTES, 2); assertContains(indexUpdates, 3, ROW, KeyValue.Type.DeleteFamily, FAM, new byte[0] , 3); assertContains(indexUpdates, ColumnTracker.NO_NEWER_PRIMARY_TABLE_ENTRY_TIMESTAMP, ROW, KeyValue.Type.Put, FAM, QueryConstants.EMPTY_COLUMN_BYTES, 3); assertContains(indexUpdates, 4, ROW, KeyValue.Type.DeleteFamily, FAM, new byte[0] , 4); assertContains(indexUpdates, ColumnTracker.NO_NEWER_PRIMARY_TABLE_ENTRY_TIMESTAMP, ROW, KeyValue.Type.Put, FAM, QueryConstants.EMPTY_COLUMN_BYTES, 4); }
@Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { LocalTableState state = new LocalTableState(localTable, mutation); IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }
NonTxIndexBuilder extends BaseIndexBuilder { @Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { LocalTableState state = new LocalTableState(localTable, mutation); IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); } }
NonTxIndexBuilder extends BaseIndexBuilder { @Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { LocalTableState state = new LocalTableState(localTable, mutation); IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }  }
NonTxIndexBuilder extends BaseIndexBuilder { @Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { LocalTableState state = new LocalTableState(localTable, mutation); IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }  @Override void setup(RegionCoprocessorEnvironment env); @Override Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData); @Override Collection<Pair<Mutation, byte[]>> getIndexUpdateForFilteredRows(Collection<KeyValue> filtered, IndexMetaData indexMetaData); }
NonTxIndexBuilder extends BaseIndexBuilder { @Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { LocalTableState state = new LocalTableState(localTable, mutation); IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }  @Override void setup(RegionCoprocessorEnvironment env); @Override Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData); @Override Collection<Pair<Mutation, byte[]>> getIndexUpdateForFilteredRows(Collection<KeyValue> filtered, IndexMetaData indexMetaData);  }