Search code examples
javahbaseavroapache-phoenix

Java objects to Hbase


I'm currently using KITE API + AVRO to handle java objects to HBase. But due to various problems I'm looking for an alternative. I've been reading about:

  • Phoenix

  • Native Hbase Api.

But there is more an alternative? . The idea is to save and to load the java objects to Hbase and uses them in a java application.


Solution

  • If you're storing your objects in the Value portion of the KeyValue pair, then it's really just an array / sequence of bytes (i.e. in the code for KeyValue class there is a getValue method which returns a byte array).

    At this point, you're down to object serialization and there are a host of libraries you can use with various ease of use, performance characteristics, and details of implementation. Avro is one type of serialization library which stores the schema with each record, but you could in theory use:

    • Standard Java serialization (implement Serializable)
    • Kryo
    • Protobuf

    Just to name a few. You may want to investigate the various strengths of each library & its tradeoffs and balance that against the type of objects you plan to store (i.e. are they all effectively the same type of object or do they vary widely in type? Are they going to be long lived i.e. years and have the expectation of schema evolution & backwards compatibility etc.)