4

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.

kliew
  • 3,073
  • 1
  • 14
  • 25
Gui Pinto
  • 57
  • 9

3 Answers3

5

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.)

dev.glitch
  • 221
  • 1
  • 6
1

Phoenix is a JDBC api to HBase. It handles most SQL types (except intervals) - you can store arbitrary java objects using the binary data type. But if you are only storing binary data, you could easily stick with HBase. If you can coerce your data in standard SQL types, Phoenix may be a good option.

kliew
  • 3,073
  • 1
  • 14
  • 25
1

If you want to stick with the Hadoop/HBase code you can have your complex class implement org.apache.hadoop.io.Writable.

// Some complex java object
// that implements org.apache.hadoop.io.Writable
SomeObject myObject = new SomeObject();

// write the object to a byte array
// for storage in HBase
byte[] byteArr = WritableUtils.toByteArray(myObject);

Reference

Community
  • 1
  • 1
Boo Radley
  • 684
  • 1
  • 13
  • 25