DefaultHBaseSerde implements HBaseSerde { @Override public Put convertToPut(Row row) { Put put = new Put(buildRowKey(row)); for (Map.Entry<String, ColumnDef> column : columns.entrySet()) { if (!column.getValue().cf.equals("rowkey")) { byte[] value = getColumnValueAsBytes(column.getValue().name, column.getValue().type, row); if (value != null) { put.addColumn(Bytes.toBytes(column.getValue().cf), Bytes.toBytes(column.getValue().name), value); } } } return put; }  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 testConvertToPut() { 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"); Row row = new RowWithSchema(fullSchema, "GOOG", 1000L, "abcd", 100, 10, 5); Put put = serde.convertToPut(row); assertArrayEquals("Row key should be GOOG:1000L", rowKey, put.getRow()); assertTrue("cf1:clordid should be abcd", put.has(cf, clordid, Bytes.toBytes("abcd"))); assertTrue("cf1:orderqty should be 100", put.has(cf, orderqty, Bytes.toBytes(100))); assertTrue("cf1:leavesqty should be 5", put.has(cf, leavesqty, Bytes.toBytes(5))); assertTrue("cf1:cumqty should be 10", put.has(cf, cumqty, Bytes.toBytes(10))); }