Reply
Contributor
Posts: 26
Registered: ‎10-13-2016
Accepted Solution

Getting hbase rowkey in morphlines

Hi,

 

I am using extractHBaseCells morphlines command to index hbase data into solr.

How do I get HBase rowkey?

 

I would like to construct a URI-based ID from the given rowkey as follows:

 

          setValues: {
            id : "http://hbase_ids.com/@{rowkey}"
          }

 

Thanks, 

Gin 

Contributor
Posts: 26
Registered: ‎10-13-2016

Re: Getting hbase rowkey in morphlines

I have looked at the source code. The most maintenance-friendly solution would be to create a custom mapper class and do some "hacks" there.

However, the provided mapper classes are final (thus no decent reuse) and I haven't found a way to configure hbase-indexer classpath via Cloudera manager.
Highlighted
Contributor
Posts: 26
Registered: ‎10-13-2016

Re: Getting hbase rowkey in morphlines

Found the solution!
https://groups.google.com/forum/#!searchin/hbase-indexer-user/rowkey%7Csort:relevance/hbase-indexer-...

Post by Wolfgang:

You can fetch it (edited: the rowkey) by pasting this code snippet into a “java” morphline command:
org.apache.hadoop.hbase.client.Result result = (org.apache.hadoop.hbase.client.Result) record.getFirstValue("_attachment_body");
byte[] rowKey = result.getRow(); 
record.put("myRowKey", rowKey);
Possible gotcha: Make sure that this java command appears *before* the extractHBaseCells morphline command in the morphline config file.
http://kitesdk.org/docs/current/morphlines/morphlines-reference-guide.html#java

Gin

Announcements