Search in sources :

Example 6 with MultiMutation

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);
}
Also used : MultiMutation(org.apache.phoenix.hbase.index.MultiMutation) ImmutableBytesPtr(org.apache.phoenix.hbase.index.util.ImmutableBytesPtr) Put(org.apache.hadoop.hbase.client.Put) Pair(org.apache.hadoop.hbase.util.Pair) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 7 with MultiMutation

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());
}
Also used : MultiMutation(org.apache.phoenix.hbase.index.MultiMutation) Pair(org.apache.hadoop.hbase.util.Pair) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 8 with MultiMutation

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);
}
Also used : MultiMutation(org.apache.phoenix.hbase.index.MultiMutation)

Aggregations

MultiMutation (org.apache.phoenix.hbase.index.MultiMutation)8 ImmutableBytesPtr (org.apache.phoenix.hbase.index.util.ImmutableBytesPtr)6 Pair (org.apache.hadoop.hbase.util.Pair)4 Mutation (org.apache.hadoop.hbase.client.Mutation)3 Put (org.apache.hadoop.hbase.client.Put)3 ColumnReference (org.apache.phoenix.hbase.index.covered.update.ColumnReference)3 BaseConnectionlessQueryTest (org.apache.phoenix.query.BaseConnectionlessQueryTest)3 Test (org.junit.Test)3 Cell (org.apache.hadoop.hbase.Cell)2 Result (org.apache.hadoop.hbase.client.Result)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TableName (org.apache.hadoop.hbase.TableName)1 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 Scan (org.apache.hadoop.hbase.client.Scan)1 ScanRanges (org.apache.phoenix.compile.ScanRanges)1 SkipScanFilter (org.apache.phoenix.filter.SkipScanFilter)1 KeyRange (org.apache.phoenix.query.KeyRange)1 Transaction (org.apache.tephra.Transaction)1