Ramasubramanian Narayanan... 2013-02-07, 15:49
Ramasubramanian Narayanan... 2013-02-08, 05:18
-Re: How to use put command in Java for dynamic field name creation
Jean-Marc Spaggiari 2013-02-08, 13:53
I think I understand the way you want to build your table, but what
I'm not sure is, what's the issue?
Are you asking how to write java code? If so, you put code should look
byte tableName = Bytes.toBytes("branch");
byte row = Bytes.toBytes("1");
byte columnFamilly = Bytes.toBytes("cf1");
byte column = Bytes.toBytes("CCY" + currencyField);
byte data = Bytes.toBytes(currencyField + currencyName);
Put put = new Put (row).add(columnFamilly, column, data);
HTable table = new HTable (tableName);
Is that what you are looking for? I wrote that on the email directly
so there might be some compilation issues, but that should give you an
idea. There is many issues with this scenario, like using "1" as the
rowkey will most probably hotspot a server, and the table might be
cached if you are doing more than one put, or use a .put(List<Put>)...
And so on.
2013/2/8, Ramasubramanian Narayanan <[EMAIL PROTECTED]>:
> Can someone help on this pls..
> On Thu, Feb 7, 2013 at 9:19 PM, Ramasubramanian Narayanan <
> [EMAIL PROTECTED]> wrote:
>> 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
>> 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
>> 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