phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Li <shawnli...@gmail.com>
Subject Re: How to decode composite rowkey back to original primary keys
Date Tue, 15 Jan 2019 02:36:18 GMT
Thanks, James. Will try it.

Shawn

On Mon, Jan 14, 2019 at 8:52 PM James Taylor <jamestaylor@apache.org> wrote:

> You can do something similar to PhoenixRuntime.decodeColumnValues() to do
> that. It'd be something like this:
>
>     public static Object[] decodeColumnValues(Connection conn, String
> fullTableName, byte[] value) throws SQLException {
>         PTable table = getTable(conn, fullTableName);
>         RowKeySchema schema = table.getRowKeySchema();
>         ImmutableBytesWritable ptr = new ImmutableBytesWritable(value);
>         schema.iterator(ptr);
>         int i = 0;
>         List<Object> values = new ArrayList<Object>();
>         while(schema.next(ptr, i, maxOffset) != null) {
>             values.add(schema.getField(i).getDataType().toObject(ptr));
>             i++;
>         }
>         return values.toArray();
>     }
>
>
>
>
> On Mon, Jan 14, 2019 at 12:47 PM Shawn Li <shawnlijob@gmail.com> wrote:
>
>> Hi,
>>
>> Phoenix encodes composite key to hbase rowkey. We want to check if there
>> any documentation or example to show how to manually decode Hbase rowkey
>> back to original values for those primary keys. Or is there any phoenix
>> source code we can directly use to do this?
>>
>> Thanks,
>> Shawn
>>
>

Mime
View raw message