Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/45#discussion_r26272833
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/schema/types/PInteger.java ---
    @@ -272,4 +273,10 @@ public PhoenixArray newArray(PDataType type, Object[] 
elements) {
           };
         }
       }
    +
    +  @Override
    +  public int getSign(byte[] bytes, int offset, int length, SortOrder 
sortOrder,
    +          Integer maxLength, Integer scale) {
    +      return SignUtils.getSignForSignedInteger(bytes, offset, length, 
sortOrder, Bytes.SIZEOF_INT);
    --- End diff --
    
    Same idea here. Create an intermediate class, called PWholeNumber or 
PWholeNumeric and derive PLong, PInteger, PShort, PByte and all the unsigned 
variations from this one. Then you can do something like this:
    
        long l = getCodec().decodeLong(bytes, offset, sortOrder);
        return l == 0 ? 0 : l < 0 ? -1 : 1; // Or maybe a mask of the most 
significant bit is better?



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to