Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Getting hbase rowkey in morphlines

avatar
Rising Star

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

avatar
Rising Star

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

View solution in original post

2 REPLIES 2

avatar
Rising Star
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.

avatar
Rising Star

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