Java Code Examples for org.apache.hadoop.hbase.client.Put#addImmutable()

The following examples show how to use org.apache.hadoop.hbase.client.Put#addImmutable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NonTxIndexBuilderTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * 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);

    CachedLocalTable cachedLocalTable = CachedLocalTable.build(
            Collections.singletonList(mutation),
            this.mockIndexMetaData,
            this.indexBuilder.getEnv().getRegion());

    Collection<Pair<Mutation, byte[]>> indexUpdates =
            indexBuilder.getIndexUpdate(mutation, mockIndexMetaData, cachedLocalTable);
    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);
}
 
Example 2
Source File: IndexSplitTransaction.java    From phoenix with Apache License 2.0 5 votes vote down vote up
public Put addLocation(final Put p, final ServerName sn, long openSeqNum) {
  p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
    Bytes.toBytes(sn.getHostAndPort()));
  p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
    Bytes.toBytes(sn.getStartcode()));
  p.addImmutable(HConstants.CATALOG_FAMILY, HConstants.SEQNUM_QUALIFIER,
      Bytes.toBytes(openSeqNum));
  return p;
}
 
Example 3
Source File: NonTxIndexBuilderTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private MultiMutation getMultipleVersionMutation(int versions) {
    MultiMutation mutation = new MultiMutation(new ImmutableBytesPtr(ROW));
    for (int i = versions - 1; i >= 0; i--) {
        Put put = new Put(ROW);
        put.addImmutable(FAM, INDEXED_QUALIFIER, i, Bytes.toBytes(i));
        mutation.addAll(put);
    }
    return mutation;
}