carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] carbondata pull request #1065: [CARBONDATA-1196] Add 3 bytes data type suppo...
Date Wed, 21 Jun 2017 05:02:07 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1065#discussion_r123154384
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/util/ByteUtil.java ---
    @@ -465,6 +465,39 @@ public static short toShort(byte[] bytes, int offset, final int length)
{
       }
     
       /**
    +   * int => byte[3]
    +   * supported range is [-8388607, 8388607], note that Math.pow(2, 24) == 8388608
    +   */
    +  public static byte[] to3Bytes(int val) {
    +    assert val <= Math.pow(2, 23) && val >= (-Math.pow(2, 23) - 1);
    +
    +    int value = val < 0 ? -val : val;
    +    byte[] b = new byte[3];
    +    b[0] = (byte) (value & 0xFF);
    +    b[1] = (byte) ((value >>> 8) & 0xFF);
    +    b[2] = (byte) ((value >>> 16) & 0x7F);
    --- End diff --
    
    Because in line474, value is converted to absolute value, so in line479 it needs to keep
the "sign bit", otherwise the "sign bit" information will be lost


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message