/** * Tests getting an index update for a mutation with 200 versions Before, the issue PHOENIX-3807 * was causing this test to take >90 seconds, so here we set a timeout of 5 seconds */ @Test(timeout = 10000) public void testManyVersions() throws IOException { // when doing a rebuild, we are replaying mutations so we want to ignore newer mutations // see LocalTable#getCurrentRowState() Mockito.when(mockIndexMetaData.getReplayWrite()).thenReturn(ReplayWrite.INDEX_ONLY); MultiMutation mutation = getMultipleVersionMutation(200); currentRowCells = mutation.getFamilyCellMap().get(FAM); Collection<Pair<Mutation, byte[]>> indexUpdates = Lists.newArrayList(); for (Mutation m : IndexManagementUtil.flattenMutationsByTimestamp(Collections.singletonList(mutation))) { indexUpdates.addAll(indexBuilder.getIndexUpdate(m, mockIndexMetaData)); } assertNotEquals(0, indexUpdates.size()); }
/** * Tests that updating an indexed column results in a DeleteFamily (prior index cell) and a Put * (new index cell) */ @Test public void testGetMutableIndexUpdate() throws IOException { setCurrentRowState(FAM, INDEXED_QUALIFIER, 1, VALUE_1); // update ts and value Put put = new Put(ROW); put.addImmutable(FAM, INDEXED_QUALIFIER, 2, VALUE_2); MultiMutation mutation = new MultiMutation(new ImmutableBytesPtr(ROW)); mutation.addAll(put); Collection<Pair<Mutation, byte[]>> indexUpdates = indexBuilder.getIndexUpdate(mutation, mockIndexMetaData); assertEquals(2, indexUpdates.size()); assertContains(indexUpdates, 2, ROW, KeyValue.Type.DeleteFamily, FAM, new byte[0] /* qual not needed */, 2); assertContains(indexUpdates, ColumnTracker.NO_NEWER_PRIMARY_TABLE_ENTRY_TIMESTAMP, ROW, KeyValue.Type.Put, FAM, QueryConstants.EMPTY_COLUMN_BYTES, 2); }
indexUpdates.addAll(indexBuilder.getIndexUpdate(m, mockIndexMetaData));