[ https://issues.apache.org/jira/browse/HBASE-10771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13965067#comment-13965067 ]
Matt Corgan commented on HBASE-10771: ------------------------------------- taking a look at patch_2 after a mention in HBASE-10861 {code}Pair<Long, Integer> getVLong(int index) throws IOException{code}this returns a fairly heavyweight object. maybe it should just return a primitive long and we could have a public static method "int numVLongBytes(long n)" that quickly computes the number of bytes. here is a different VLong format i wrote a while back. i don't know what the numBytes formula for this particular VLong would be, but you can see how efficiently it could possibly be calculated. probably much cheaper than creating 3 objects {code} public static int numBytes(long in){// do a check for illegal arguments if not protected if(in == 0){ return 1; }// doesn't work with the formula below return (70 - Long.numberOfLeadingZeros(in)) / 7;// 70 comes from 64+(7-1) } public static byte[] getBytes(long value){ int numBytes = numBytes(value); byte[] bytes = new byte[numBytes]; long remainder = value; for(int i = 0; i < numBytes - 1; ++i){ bytes[i] = (byte)((remainder & LONG_7_RIGHT_BITS_SET) | LONG_8TH_BIT_SET);// set the left bit remainder >>= 7; } bytes[numBytes - 1] = (byte)(remainder & LONG_7_RIGHT_BITS_SET);// do not set the left bit return bytes; } {code} also not sure the checked IOException is necessary since all of these methods could encounter similar corruption errors, plus the actual IO has presumably already been done earlier. {code} + @Override + public long getLong(int index) { + return Bytes.toLong(bytes, index); + } {code} does the hbase Bytes util have the exact same format that ByteBuffers use? native java format can be seen in java.nio.Bits.java > Primitive type put/get APIs in ByteRange > ----------------------------------------- > > Key: HBASE-10771 > URL: https://issues.apache.org/jira/browse/HBASE-10771 > Project: HBase > Issue Type: Improvement > Reporter: Anoop Sam John > Assignee: Anoop Sam John > Fix For: 0.99.0 > > Attachments: HBASE-10771.patch, HBASE-10771_V2.patch > > > While doing HBASE-10713 I came across the need to write int/long (and read > also) from a ByteRange. CellBlocks are backed by ByteRange. So we can add > such APIs. > Also as per HBASE-10750 we return a ByteRange from MSLAB and also discussion > under HBASE-10191 suggest we can have BR backed HFileBlocks etc. -- This message was sent by Atlassian JIRA (v6.2#6252)