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

Vikas Vishwakarma commented on HBASE-17877:
-------------------------------------------

[~Apache9] , I am copying the code below:

{code}
public class MyBenchmark {
        static byte[] ba1_8;
        static byte[] ba2_8;
...
        static {                 
                Random r = new Random();
                ba1_8 = new byte[8];
                ba2_8 = new byte[8];
                r.nextBytes(ba1_8);
                r.nextBytes(ba2_8);
....
        }

    @GenerateMicroBenchmark
    @Fork(1)
    @BenchmarkMode(Mode.Throughput)
    @Warmup(iterations = 20, time = 1, timeUnit = TimeUnit.SECONDS)
    @Measurement(iterations = 50, time = 1, timeUnit = TimeUnit.SECONDS)
    public void testHBaseComparator8(BlackHole b) {
        // place your benchmarked code here
        b.consume(ByteArrayComparator.compareToHbase(ba1_8, 0, ba1_8.length, 
ba2_8, 0, ba2_8.length));
    }
... 
//Similarly for HBase/Hadoop/Guava101 for byte array size from 4 to 16K


int compareToHbase(byte[] buffer1, int offset1, int length1,
        byte[] buffer2, int offset2, int length2) {
                final int minLength = Math.min(length1, length2);
                // Changing input random index using random byte before running 
compare
                int indx = r.nextInt(minLength);
                int cindx = r.nextInt(byteArrLen);
                buffer1[indx] = byteArr[cindx];
                buffer2[indx] = byteArr[cindx];
....
//Remaining HBase comparator code

    }

}
{code}


> Replace/improve HBase's byte[] comparator
> -----------------------------------------
>
>                 Key: HBASE-17877
>                 URL: https://issues.apache.org/jira/browse/HBASE-17877
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Lars Hofhansl
>            Assignee: Vikas Vishwakarma
>         Attachments: 17877-1.2.patch, 17877-v2-1.3.patch, 17877-v3-1.3.patch, 
> 17877-v4-1.3.patch, ByteComparatorJiraHBASE-17877.pdf, 
> HBASE-17877.branch-1.3.001.patch, HBASE-17877.branch-1.3.002.patch, 
> HBASE-17877.master.001.patch, HBASE-17877.master.002.patch
>
>
> [~vik.karma] did some extensive tests and found that Hadoop's version is 
> faster - dramatically faster in some cases.
> Patch forthcoming.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to