Apache Storm Component Guide
Also available as:
PDF
loading table of contents...

Writing Data to HBase

The storm-hbase connector enables Storm developers to collect several PUTS in a single operation and write to multiple HBase column families and counter columns. A PUT is an HBase operation that inserts data into a single HBase cell. Use the HBase client's write buffer to automatically batch: hbase.client.write.buffer.

The primary interface in the storm-hbase connector is the org.apache.storm.hbase.bolt.mapper.HBaseMapper interface. However, the default implementation, SimpleHBaseMapper, writes a single column family. Storm developers can implement the HBaseMapper interface themselves or extend SimpleHBaseMapper if they want to change or override this behavior.

SimpleHBaseMapper Methods

withRowKeyField

Specifies the row key for the target HBase row. A row key uniquely identifies a row in HBase

withColumnFields

Specifies the target HBase column.

withCounterFields

Specifies the target HBase counter.

withColumnFamily

Specifies the target HBase column family.

Example

The following example specifies the 'word' tuple as the row key, adds an HBase column for the tuple 'word' field, adds an HBase counter column for the tuple 'count' field, and writes data to the 'cf' column family.

SimpleHBaseMapper mapper = new SimpleHBaseMapper()
 .withRowKeyField("word")
 .withColumnFields(new Fields("word"))
 .withCounterFields(new Fields("count"))
 .withColumnFamily("cf");