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

    https://github.com/apache/phoenix/pull/45#discussion_r26272695
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDouble.java ---
    @@ -308,4 +309,28 @@ public PhoenixArray newArray(PDataType type, Object[] 
elements) {
           };
         }
       }
    +
    +    @Override
    +    public int getSign(byte[] bytes, int offset, int length, SortOrder 
sortOrder,
    +            Integer maxLength, Integer scale) {
    +        Preconditions.checkNotNull(sortOrder);
    +        checkForSufficientLength(bytes, offset, Bytes.SIZEOF_LONG);
    +        if (sortOrder == SortOrder.DESC) {
    +            bytes =
    +                    SortOrder.invert(bytes, offset, new 
byte[Bytes.SIZEOF_DOUBLE], 0,
    +                        Bytes.SIZEOF_DOUBLE);
    +            offset = 0;
    +        }
    --- End diff --
    
    To prevent the creation of a Long, you can use the following and remove 
your sortOrder logic to get the double here:
        double d = getCodec().decodeDouble(bytes, offset, sortOrder);
    
    Then you can use Math.signum(d) to get the sign for simplification. Note 
that this code will work for PFloat, PDouble, PUnsignedFloat, and 
PUnsignedDouble, so it's probably worth having another intermediate class here, 
something like PRealNumber.



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