Can you provide an example of one of the rowkeys, the values you are expecting 
out of it, and the full table definition? Of importance in the table definition 
will be whether you have salt buckets defined.

Michael McAllister
Staff Data Warehouse Engineer | Decision Systems
[email protected]<mailto:[email protected]> | C: 512.423.7447 | 
skype: michael.mcallister.ha<mailto:[email protected]> | webex: 
https://h.a/mikewebex
[cid:[email protected]]
This electronic communication (including any attachment) is confidential.  If 
you are not an intended recipient of this communication, please be advised that 
any disclosure, dissemination, distribution, copying or other use of this 
communication or any attachment is strictly prohibited.  If you have received 
this communication in error, please notify the sender immediately by reply 
e-mail and promptly destroy all electronic and printed copies of this 
communication and any attachment.

From: Anil <[email protected]>
Reply-To: "[email protected]" <[email protected]>
Date: Thursday, August 25, 2016 at 1:09 AM
To: "[email protected]" <[email protected]>
Subject: Re: Extracting column values from Phoenix composite primary key

HI Michael,

Thank you for the response.

Unfortunately, that is not working.

Following is the snippet. one of the column is unsigned long and trying to 
extract the last column (with value target in the below code).
please correct me if i am doing wrong.

       byte SEPARATOR_BYTE = 0;
    byte[] SEPARATOR_BYTE_ARRAY = { 0 };
    byte[] startRow = ByteUtil.concat(
PVarchar.INSTANCE.toBytes("test"),
QueryConstants.SEPARATOR_BYTE_ARRAY,
PVarchar.INSTANCE.toBytes("src"),
QueryConstants.SEPARATOR_BYTE_ARRAY,
PVarchar.INSTANCE.toBytes("label"),
QueryConstants.SEPARATOR_BYTE_ARRAY,
PVarchar.INSTANCE.toBytes("direction"),
QueryConstants.SEPARATOR_BYTE_ARRAY,
PUnsignedLong.INSTANCE.toBytes(1235464603853L),
PVarchar.INSTANCE.toBytes("target"));


List<String> cols = new ArrayList<String>();
    int j = 0;
    for (int i= 0 ; i < startRow.length ; i++){
    if (startRow[i] == SEPARATOR_BYTE){
    cols.add(Bytes.toString(startRow, j, i-j));
    j = i+1;
    }
    }

    cols.add(Bytes.toString(startRow, j, startRow.length - j));

System.out.println(cols.size());

String rowKey = Bytes.toString(startRow);
String[] columns = rowKey.split("\u0000");

System.out.println(columns.length);

last entry in the array has special character too along with actual value.

Can you point out the bug in the above code if any. Thanks.

Regards,
Anil


On 25 August 2016 at 02:32, Michael McAllister 
<[email protected]<mailto:[email protected]>> wrote:
Anil

If you split the rowkey on the zero byte character, you should end up with the 
individual columns that made up your primary key. Details are here:-

https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table

Michael McAllister
Staff Data Warehouse Engineer | Decision Systems
[email protected]<mailto:[email protected]> | C: 512.423.7447 | 
skype: michael.mcallister.ha<mailto:[email protected]> | webex: 
https://h.a/mikewebex
[cid:[email protected]]
This electronic communication (including any attachment) is confidential.  If 
you are not an intended recipient of this communication, please be advised that 
any disclosure, dissemination, distribution, copying or other use of this 
communication or any attachment is strictly prohibited.  If you have received 
this communication in error, please notify the sender immediately by reply 
e-mail and promptly destroy all electronic and printed copies of this 
communication and any attachment.

From: Anil <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, August 24, 2016 at 4:10 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: Extracting column values from Phoenix composite primary key

Any inputs ? Thanks.

On 24 August 2016 at 11:13, Anil 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

I have created primary key with columns in phoenix.
is there any way to extract the column values from hbase row key ? Please help.

Thanks,
Anil


Reply via email to