DefaultHBaseSerde implements HBaseSerde { @Override public List<Row> convertFromResults(Iterable<Result> results) { List<Row> rows = Lists.newArrayList(); for (Result result : results) { rows.add(convertFromResult(result)); } return rows; }  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 testConvertFromResults() { byte[] rowKey = Bytes.add(Bytes.toBytes("GOOG:"), Bytes.toBytes(1000L)); 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<Cell> cells1 = Lists.newArrayList( (Cell)new KeyValue(rowKey, cf, clordid, 1000L, Bytes.toBytes("abcd")), new KeyValue(rowKey, cf, orderqty, 1000L, Bytes.toBytes(100)), new KeyValue(rowKey, cf, leavesqty, 1000L, Bytes.toBytes(10)), new KeyValue(rowKey, cf, cumqty, 1000L, Bytes.toBytes(5)) ); Result result1 = Result.create(cells1); byte[] rowKey2 = Bytes.add(Bytes.toBytes("AAPL:"), Bytes.toBytes(1004L)); List<Cell> cells2 = Lists.newArrayList( (Cell)new KeyValue(rowKey2, cf, clordid, 1004L, Bytes.toBytes("efgh")), new KeyValue(rowKey2, cf, orderqty, 1004L, Bytes.toBytes(99)), new KeyValue(rowKey2, cf, leavesqty, 1004L, Bytes.toBytes(9)), new KeyValue(rowKey2, cf, cumqty, 1004L, Bytes.toBytes(4)) ); Result result2 = Result.create(cells2); List<Row> rows = serde.convertFromResults(Lists.newArrayList(result1, result2)); assertEquals("Two Rows should be returned", 2, rows.size()); assertEquals("Symbol should be GOOG", "GOOG", rows.get(0).<String>getAs("symbol")); assertEquals("Transacttime should be 1000L", 1000L, rows.get(0).<Long>getAs("transacttime").longValue()); assertEquals("Clordid should be abcd", "abcd", rows.get(0).<String>getAs("clordid")); assertEquals("Orderqty should be 100", 100, rows.get(0).<Integer>getAs("orderqty").intValue()); assertEquals("Leavesqty should be 10", 10, rows.get(0).<Integer>getAs("leavesqty").intValue()); assertEquals("Cumqty should be 5", 5, rows.get(0).<Integer>getAs("cumqty").intValue()); assertEquals("Symbol should be AAPL", "AAPL", rows.get(1).<String>getAs("symbol")); assertEquals("Transacttime should be 1004L", 1004L, rows.get(1).<Long>getAs("transacttime").longValue()); assertEquals("Clordid should be efgh", "efgh", rows.get(1).<String>getAs("clordid")); assertEquals("Orderqty should be 99", 99, rows.get(1).<Integer>getAs("orderqty").intValue()); assertEquals("Leavesqty should be 9", 9, rows.get(1).<Integer>getAs("leavesqty").intValue()); assertEquals("Cumqty should be 4", 4, rows.get(1).<Integer>getAs("cumqty").intValue()); }