Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Getting hbase rowkey in morphlines

Solved Go to solution

Getting hbase rowkey in morphlines

Contributor

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 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Getting hbase rowkey in morphlines

Contributor

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

2 REPLIES 2
Highlighted

Re: Getting hbase rowkey in morphlines

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

Re: Getting hbase rowkey in morphlines

Contributor

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