trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sureshsubbiah <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #882: TMUDF fixes and related changes
Date Thu, 22 Dec 2016 15:35:31 GMT
Github user sureshsubbiah commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/882#discussion_r93643561
  
    --- Diff: core/sql/src/main/java/org/trafodion/sql/udr/TupleInfo.java ---
    @@ -1079,19 +1230,48 @@ else if (t.getByteLength() == 8)
                 row_.putLong(t.getDataOffset(), val);
                 break;
     
    +        case TINYINT_UNSIGNED:
    +            if (val < 0 || val > Byte.MAX_VALUE)
    +                if (val > (2 * Byte.MAX_VALUE + 1))
    +                    throw new UDRException(
    +                        38900,
    +                        "Overflow/underflow when assigning to TINYINT UNSIGNED type");
    +                else
    +                    // use the signed value that has the same bit
    +                    // pattern as the desired unsigned value, since
    +                    // Java doesn't support "unsigned" basic types
    +                    val = val + Byte.MIN_VALUE + Byte.MIN_VALUE;
    --- End diff --
    
    I suppose this is basic arithmetic. If the comment could please include an example that
will help. Is Byte.MIN_VALUE = -127. If yes, how will adding it twice to val, give the same
bit pattern as the unsigned type? I am quite sure there is no defect here, but that I am not
understanding something obvious. Thanks.


---
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