DefaultHBaseSerde implements HBaseSerde { @Override public Row convertFromResult(Result result) { Object[] values = new Object[schema.length()]; byte[] rowKey = result.getRow(); int index = 0; for (int i = 0; i < keyColumns.size(); i++) { ColumnDef def = columns.get(keyColumns.get(i)); index += addColumnValue(rowKey, index, rowKey.length, values, def.type, schema.fieldIndex(def.name), keySeparator, i == keyColumns.size() - 1); if (i < keyColumns.size() - 1) { index += keySeparator.length; } } for (Cell cell : result.listCells()) { String cellName = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); ColumnDef def = columns.get(cellName); values[schema.fieldIndex(def.name)] = getColumnValue(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength(), def.type); } return new RowWithSchema(schema, values); }  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 testConvertFromResult() { 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> cells = 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 result = Result.create(cells); Row row = serde.convertFromResult(result); assertEquals("Symbol should be GOOG", "GOOG", row.<String>getAs("symbol")); assertEquals("Transacttime should be 1000L", 1000L, row.<Long>getAs("transacttime").longValue()); assertEquals("Clordid should be abcd", "abcd", row.<String>getAs("clordid")); assertEquals("Orderqty should be 100", 100, row.<Integer>getAs("orderqty").intValue()); assertEquals("Leavesqty should be 10", 10, row.<Integer>getAs("leavesqty").intValue()); assertEquals("Cumqty should be 5", 5, row.<Integer>getAs("cumqty").intValue()); }