[ https://issues.apache.org/jira/browse/PHOENIX-2142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14652072#comment-14652072 ]
James Taylor edited comment on PHOENIX-2142 at 8/3/15 4:40 PM: --------------------------------------------------------------- Thanks for the pull request, [~shuxi0ng]. Overall it looks good - one improvement would be to pre-allocate a byte array and use PInteger.INSTANCE.getCodec().encodeLong() here to prevent the creation of an Integer: {code} + public void octetLength(byte[] bytes, int offset, int length, SortOrder sortOrder, + ImmutableBytesWritable outPtr) { + outPtr.set(PInteger.INSTANCE.toBytes(Integer.valueOf(length))); + } {code} Also, function names should be upper case: {code} +public class OctetLengthFunction extends ScalarFunction { + + public static final String NAME = "octet_length"; {code} was (Author: jamestaylor): Thanks for the pull request, [~shuxi0ng]. Overall it looks good - one improvement would be to pre-allocate a byte array and use PInteger.INSTANCE.getCodec().encodeLong() here to prevent the creation of an Integer: {code} + public void octetLength(byte[] bytes, int offset, int length, SortOrder sortOrder, + ImmutableBytesWritable outPtr) { + outPtr.set(PInteger.INSTANCE.toBytes(Integer.valueOf(length))); + } {code} > Implement octet_length build-in function for BINARY and VARBINARY > ----------------------------------------------------------------- > > Key: PHOENIX-2142 > URL: https://issues.apache.org/jira/browse/PHOENIX-2142 > Project: Phoenix > Issue Type: Sub-task > Reporter: Shuxiong Ye > Assignee: Shuxiong Ye > Attachments: > 0001-PHOENIX-2142-Implement-octet_length-build-in-functio.patch > > > See PHOENIX-1664 -- This message was sent by Atlassian JIRA (v6.3.4#6332)