@Test public void testMultipleColumnFamiliesWithSameQualifiers() { byte[] rowKey = dataHelper.randomData("rk1-"); byte[] family1 = Bytes.toBytes("family1"); byte[] qualifier1 = Bytes.toBytes("qualifier1"); byte[] value1 = Bytes.toBytes("value1"); byte[] family2 = Bytes.toBytes("family2"); byte[] value2 = Bytes.toBytes("value2"); Append append = new Append(rowKey); append.add(family1, qualifier1, value1); append.add(family2, qualifier1, value2); ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(TABLE_ID, ByteString.copyFrom(rowKey)); appendAdapter.adapt(append, readModifyWriteRow); ReadModifyWriteRowRequest request = readModifyWriteRow.toProto(requestContext); List<ReadModifyWriteRule> rules = request.getRulesList(); Assert.assertEquals(2, rules.size()); Assert.assertEquals("family1", rules.get(0).getFamilyName()); Assert.assertEquals("qualifier1", rules.get(0).getColumnQualifier().toStringUtf8()); Assert.assertEquals("value1", rules.get(0).getAppendValue().toStringUtf8()); Assert.assertEquals("family2", rules.get(1).getFamilyName()); Assert.assertEquals("qualifier1", rules.get(1).getColumnQualifier().toStringUtf8()); Assert.assertEquals("value2", rules.get(1).getAppendValue().toStringUtf8()); }
@Override public void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow) { for (Map.Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { String familyName = Bytes.toString(entry.getKey()); List<Cell> cells = CellDeduplicationHelper.deduplicateFamily(operation, entry.getKey()); for (Cell cell : cells) { readModifyWriteRow.append( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), ByteString.copyFrom( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } } }
AppendAdapter implements OperationAdapter<Append, ReadModifyWriteRow> { @Override public void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow) { for (Map.Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { String familyName = Bytes.toString(entry.getKey()); List<Cell> cells = CellDeduplicationHelper.deduplicateFamily(operation, entry.getKey()); for (Cell cell : cells) { readModifyWriteRow.append( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), ByteString.copyFrom( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } } } }
AppendAdapter implements OperationAdapter<Append, ReadModifyWriteRow> { @Override public void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow) { for (Map.Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { String familyName = Bytes.toString(entry.getKey()); List<Cell> cells = CellDeduplicationHelper.deduplicateFamily(operation, entry.getKey()); for (Cell cell : cells) { readModifyWriteRow.append( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), ByteString.copyFrom( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } } }  }
AppendAdapter implements OperationAdapter<Append, ReadModifyWriteRow> { @Override public void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow) { for (Map.Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { String familyName = Bytes.toString(entry.getKey()); List<Cell> cells = CellDeduplicationHelper.deduplicateFamily(operation, entry.getKey()); for (Cell cell : cells) { readModifyWriteRow.append( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), ByteString.copyFrom( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } } }  @Override void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow); }
AppendAdapter implements OperationAdapter<Append, ReadModifyWriteRow> { @Override public void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow) { for (Map.Entry<byte[], List<Cell>> entry : operation.getFamilyCellMap().entrySet()) { String familyName = Bytes.toString(entry.getKey()); List<Cell> cells = CellDeduplicationHelper.deduplicateFamily(operation, entry.getKey()); for (Cell cell : cells) { readModifyWriteRow.append( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), ByteString.copyFrom( cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } } }  @Override void adapt(Append operation, ReadModifyWriteRow readModifyWriteRow);  }