HBase Mapping - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

It was mentioned above that you the default mapping strategies are header and body mapping.

Below you can find some detailed examples of how each mapping strategy works.

HBase Header mapping Examples

The header mapping is the default mapping.

To put the value "myvalue" into HBase row "myrow" and column "myfamily:mycolum" the message should contain the following headers:

Header

Value

CamelHBaseRowId

myrow

CamelHBaseFamily

myfamily

CamelHBaseQualifier

myqualifier

CamelHBaseValue

myvalue

To put more values for different columns and / or different rows you can specify additional headers suffixed with the index of the headers, e.g:

Header

Value

CamelHBaseRowId

myrow

CamelHBaseFamily

myfamily

CamelHBaseQualifier

myqualifier

CamelHBaseValue

myvalue

CamelHBaseRowId2

myrow2

CamelHBaseFamily2

myfamily

CamelHBaseQualifier2

myqualifier

CamelHBaseValue2

myvalue2

In the case of retrieval operations such as get or scan you can also specify for each column the type that you want the data to be converted to. For exampe:

Header

Value

CamelHBaseFamily

myfamily

CamelHBaseQualifier

myqualifier

CamelHBaseValueType

Long

Please note that in order to avoid boilerplate headers that are considered constant for all messages, you can also specify them as part of the endpoint uri, as you will see below.

Body mapping Examples

In order to use the body mapping strategy you will have to specify the option mappingStrategy as part of the uri, for example:

hbase:mytable?mappingStrategy=body

To use the body mapping strategy the body needs to contain an instance of org.apache.camel.component.hbase.model.HBaseData. You can construct:

HBaseData data = new HBaseData();
HBaseRow row = new HBaseRow();
row.setId("myRowId");
HBaseCell cell = new HBaseCell();
cell.setFamily("myfamily");
cell.setQualifier("myqualifier");
cell.setValue("myValue");
row.getCells().add(cell);
data.addRows().add(row);

The object above can be used for example in a put operation and will result in creating or updating the row with id myRowId and add the value myvalue to the column myfamily:myqualifier.

The body mapping strategy might not seem very appealing at first. The advantage it has over the header mapping strategy is that the HBaseData object can be easily converted to or from xml/json.