[ https://issues.apache.org/jira/browse/HBASE-21617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16742696#comment-16742696 ]
Zheng Hu commented on HBASE-21617: ---------------------------------- [~apcahephoenix], thanks for your patch. Looks good to me for the fix. while some question about the UT. why do you put the max_value & min_value to the head/tail of the byte array ? {code} + bytes[0] = Byte.MAX_VALUE; + bytes[bytes.length - 1] = Byte.MIN_VALUE; + int offset = Bytes.putBigDecimal(bytes, 1, decimal); + Assert.assertEquals(bytes.length - 1, offset) {code} btw, please reopen the review board again. and the patch name can be renamed to HBASE-21617.master.v2.patch , which will be used for hadoop QA. Thanks. > HBase Bytes.putBigDecimal error > ------------------------------- > > Key: HBASE-21617 > URL: https://issues.apache.org/jira/browse/HBASE-21617 > Project: HBase > Issue Type: Bug > Components: util > Affects Versions: 2.1.0, 2.0.0, 2.1.1 > Environment: JDK 1.8 > Reporter: apcahephoenix > Priority: Major > Attachments: Bytes_HBASE_21617.patch, TestBytes_HBASE_21617.patch > > > *hbase-common/* > *org.apache.hadoop.hbase.util.Bytes:* > public static int putBigDecimal(byte[] bytes, int offset, BigDecimal val) { > if (bytes == null){ > return offset; > } > byte[] valueBytes = val.unscaledValue().toByteArray(); > byte[] result = new byte[valueBytes.length + SIZEOF_INT]; > offset = putInt(result, offset, val.scale()); > {color:#d04437}return putBytes(result, offset, valueBytes, 0, > valueBytes.length); // this one, bytes is not used{color} > } > *Test:* > byte[] bytes = new byte[64]; > BigDecimal bigDecimal = new BigDecimal("100.10"); > Bytes.putBigDecimal(bytes, 4, bigDecimal); > System.out.println(Arrays.toString(bytes)); // invalid > *Suggest:* > public static int putBigDecimal(byte[] bytes, int offset, BigDecimal val) { > byte[] valueBytes = toBytes(val); > return putBytes(bytes, offset, valueBytes, 0, valueBytes.length); > } -- This message was sent by Atlassian JIRA (v7.6.3#76005)