phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yuhao Bi <byh0...@gmail.com>
Subject Re: Fw:Phoenix number format problem
Date Tue, 08 Nov 2016 03:06:02 GMT
Hi there,

I think it is because phoenix did some encode/decode work for different
data types.
In PTinyInt.java we have:

 public int encodeByte(byte v, byte[] b, int o) {
>
>       checkForSufficientLength(b, o, Bytes.SIZEOF_BYTE);
>
>       b[o] = (byte) (v ^ 0x80); // Flip sign bit so that Short is binary
>> comparable
>
>       return Bytes.SIZEOF_BYTE;
>
>     }
>
>
and

public byte decodeByte(byte[] b, int o, SortOrder sortOrder) {
>
>       Preconditions.checkNotNull(sortOrder);
>
>       checkForSufficientLength(b, o, Bytes.SIZEOF_BYTE);
>
>       int v;
>
>       if (sortOrder == SortOrder.ASC) {
>
>         v = b[o] ^ 0x80; // Flip sign bit back
>
>       } else {
>
>         v = b[o] ^ 0xff ^ 0x80; // Flip sign bit back
>
>       }
>
>       return (byte) v;
>
>     }
>
>
I hope this answers your question.
Maybe you would rather use native jdbc interface or you may need to do it
by yourself.

Thanks.
Yuhao.

2016-11-08 9:47 GMT+08:00 马骉 <mabiaocsu@qq.com>:

> Hi , all
>
>             I use Phoenix4.8.1 to mapping a hbase0.98 table, while I put a
> 0 (tinyInt) to hbase, the phoenix read as -80,
>
> Has any one had seen this problem yet?
>
>
>
> Thx~
>
>
>
> From: BiaoMa
>

Mime
View raw message