Yes, the method is correct. HBase stores everything in bytes. You basically do something like
byte[] key = createSomeKey();
Put put = new Put(key);
put.add(streamColumnFamily,streamColumnName,serializedData);
HTable h = ....
h.put(put);
java :
public byte[] serialize(Serializable object) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutput stream = new ObjectOutputStream(byteArrayOutputStream);
stream.writeObject(object);
stream.flush();
return byteArrayOutputStream.toByteArray()
}
public Object deserialize(byte[] bytes){
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
objectInputStream.readObject();
}
, , Integer, Long, String..., Bytes org.apache.hadoop.hbase.util