Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
HBase >> mail # user >> How to use put command in Java for dynamic field name creation


Copy link to this message
-
How to use put command in Java for dynamic field name creation
Hi,

I have a requirement to create dynamic field name (based on value of a
column)  at run time... I think this is the usual approach that we will
used in HBASE for one to many relationships..

For example, physical table has the following structure

  *Branch Number* *Branch Name* *Supported Currency Code* *Currency Name*  1
ABC INR India Rupee  1 ABC USD US Dollar  2 EFG SGD Singapore Dollar  2 EFG
INR India Rupee
Row key is Branch Number...

To flatten it out, we have to redesign the HBASE table as follows :

The fields related to currency will be grouped and created under a single
field (supported currency code & currency name) and the field name is
dynamically created as "CCY"+<actual value for supported currency code>

For the above scenario, the HBASE table will look llike following...
  *Branch Number* *Branch Name* *CCY_INR* *CCY_USD* *CCY_SGD*  1 ABC INR|India
Rupee USD|US Dollar
 2 EFG INR|India Rupee
SGD|Singapore Dollar
Now the question is,

what is the syntax for the put statement in JAVA so that the Column name is
dynamically created...

put ('branch','1','cf1:'+'CCY'+<valueof currency field>,<value of currency
field>+<value of currency name field>);

the above sytax is not working for me...

Please let me know the syntax of the put statement in this scenario using
JAVA...

regards,
Rams
+
Ramasubramanian Narayanan... 2013-02-08, 05:18
+
Jean-Marc Spaggiari 2013-02-08, 13:53