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
withRowKeyFieldSpecifies the row key for the target HBase row. A row key uniquely identifies a row in HBase
withColumnFieldsSpecifies the target HBase column.
withCounterFieldsSpecifies the target HBase counter.
withColumnFamilySpecifies 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"); 
