[ 
https://issues.apache.org/jira/browse/PHOENIX-1715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14355105#comment-14355105
 ] 

James Taylor commented on PHOENIX-1715:
---------------------------------------

{quote}
So in PNumericType, we have an abstract function getSign, which is like 
function toObject in PDataType, which we implement the details in each 
subclass, PInteger, PFloat etc.
How about the solution above?
{quote}

+1. Sounds very good.

bq. What does "SortOrder sortOrder, Integer maxLength, Integer scale" mean here?
For a primary key constraint column, we support declaring it as ascending or 
descending. This maps to the sort order being ASC or DESC. In the case of DESC, 
we invert all of the bits of the value to reverse the sorting. The maxLength is 
for CHAR(xx) or DECIMAL(xx, yy) with scale being the yy part. You won't need to 
pass these into your getSign() method, as they won't be relevant.

The best performing implementation of getSign() will operate directly on the 
byte[] rather than even converting to an Object. Take a look at 
http://phoenix.apache.org/language/datatypes.html for documentation on the 
serialization format. For DECIMAL, see PDataType.toBigDecimal(byte[] bytes, int 
offset, int length), as the sign is represented in the first byte (and there's 
a special case for zero).



> Implement Build-in math function Sign
> -------------------------------------
>
>                 Key: PHOENIX-1715
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1715
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Shuxiong Ye
>            Assignee: Shuxiong Ye
>
> Take a look at the typical math functions that are implemented in relational 
> database systems 
> (http://www.postgresql.org/docs/current/static/functions-math.html) and 
> implement the same for Phoenix in Java following this guide: 
> http://phoenix-hbase.blogspot.com/2013/04/how-to-add-your-own-built-in-function.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to