use of org.apache.phoenix.hbase.index.MultiMutation in project phoenix by apache.
the class TestNonTxIndexBuilder method testGetMutableIndexUpdate.
/**
* 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);
}
use of org.apache.phoenix.hbase.index.MultiMutation in project phoenix by apache.
the class TestNonTxIndexBuilder method testManyVersions.
/**
* 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 = 5000)
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.ignoreNewerMutations()).thenReturn(true);
MultiMutation mutation = getMultipleVersionMutation(200);
currentRowCells = mutation.getFamilyCellMap().get(FAM);
Collection<Pair<Mutation, byte[]>> indexUpdates = indexBuilder.getIndexUpdate(mutation, mockIndexMetaData);
assertNotEquals(0, indexUpdates.size());
}
use of org.apache.phoenix.hbase.index.MultiMutation in project phoenix by apache.
the class PhoenixTransactionalIndexer method addMutation.
public static void addMutation(Map<ImmutableBytesPtr, MultiMutation> mutations, ImmutableBytesPtr row, Mutation m) {
MultiMutation stored = mutations.get(row);
// we haven't seen this row before, so add it
if (stored == null) {
stored = new MultiMutation(row);
mutations.put(row, stored);
}
stored.addAll(m);
}
Aggregations