DefaultHBaseSerde implements HBaseSerde { @Override public List<Delete> convertToDeletes(List<Row> rows) { List<Delete> deletes = Lists.newArrayList(); for (Row row : rows) { deletes.add(convertToDelete(row)); } return deletes; }  void configure(Config config); @Override Query convertToQuery(Row row); @Override Row convertFromResult(Result result); @Override List<Row> convertFromResults(Iterable<Result> results); @Override Put convertToPut(Row row); @Override List<Put> convertToPuts(List<Row> rows); @Override Delete convertToDelete(Row row); @Override List<Delete> convertToDeletes(List<Row> rows);  }
@Test public void testConvertToDeletes() { byte[] cf = Bytes.toBytes("cf1"); byte[] clordid = Bytes.toBytes("clordid"); byte[] orderqty = Bytes.toBytes("orderqty"); byte[] leavesqty = Bytes.toBytes("leavesqty"); byte[] cumqty = Bytes.toBytes("cumqty"); List<Row> rows = Lists.newArrayList( (Row)new RowWithSchema(fullSchema, "GOOG", 1000L, "abcd", 100, 10, 5), new RowWithSchema(fullSchema, "AAPL", 1000L, "efgh", 99, 9, 4) ); List<Delete> deletes = serde.convertToDeletes(rows); byte[] rowKey1 = Bytes.add(Bytes.toBytes("GOOG:"), Bytes.toBytes(1000L)); assertEquals("Should be 2 deletes", 2, deletes.size()); Map<byte[], List<Cell>> contents1 = deletes.get(0).getFamilyCellMap(); assertArrayEquals("Row key should be GOOG:1000L", rowKey1, deletes.get(0).getRow()); assertTrue("Delete contains cf1", contents1.containsKey(cf)); List<Cell> cells1 = contents1.get(cf); assertEquals("Delete should have four cells", 4, cells1.size()); assertArrayEquals("Cell 0 should be cf1:clordid", clordid, CellUtil.cloneQualifier(cells1.get(0))); assertArrayEquals("Cell 1 should be cf1:cumqty", cumqty, CellUtil.cloneQualifier(cells1.get(1))); assertArrayEquals("Cell 2 should be cf1:leavesqty", leavesqty, CellUtil.cloneQualifier(cells1.get(2))); assertArrayEquals("Cell 3 should be cf1:orderqty", orderqty, CellUtil.cloneQualifier(cells1.get(3))); byte[] rowKey2 = Bytes.add(Bytes.toBytes("AAPL:"), Bytes.toBytes(1000L)); assertEquals("Should be 2 deletes", 2, deletes.size()); Map<byte[], List<Cell>> contents2 = deletes.get(1).getFamilyCellMap(); assertArrayEquals("Row key should be GOOG:1000L", rowKey2, deletes.get(1).getRow()); assertTrue("Delete contains cf1", contents2.containsKey(cf)); List<Cell> cells2 = contents2.get(cf); assertEquals("Delete should have four cells", 4, cells2.size()); assertArrayEquals("Cell 0 should be cf1:clordid", clordid, CellUtil.cloneQualifier(cells2.get(0))); assertArrayEquals("Cell 1 should be cf1:cumqty", cumqty, CellUtil.cloneQualifier(cells2.get(1))); assertArrayEquals("Cell 2 should be cf1:leavesqty", leavesqty, CellUtil.cloneQualifier(cells2.get(2))); assertArrayEquals("Cell 3 should be cf1:orderqty", orderqty, CellUtil.cloneQualifier(cells2.get(3))); }