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

Phil Yang commented on HBASE-16612:
-----------------------------------

I ran a benchmark for three methods, codeToType, using an array and using a map.
{code}
public static Type arrayToType(final byte b) {
    return ARR[0xff&b];
}

public static Type mapToType(final byte b) {
    return MAP.get(b);
}
{code}

Benchmark       Mode  Cnt          Score         Error  Units
Bench.codeToType(4)  thrpt   20  110060552.455 ± 1683158.201  ops/s
Bench.codeToType(14)  thrpt   20   89055208.888 ± 1478463.064  ops/s
Bench.arrayToType(4)  thrpt   20  298451203.883 ± 8411142.284  ops/s
Bench.arrayToType(14)  thrpt   20  299743528.870 ± 5011623.643  ops/s
Bench.mapToType(4)  thrpt   20  163042309.727 ± 3548380.929  ops/s
Bench.mapToType(14)  thrpt   20  163546726.415 ± 2980305.459  ops/s

4 is code of Put and 14 is code of DeleteFamily which is the max code of normal 
types. we can see that array has the best performance.

> Use array to cache Types for KeyValue.Type.codeToType
> -----------------------------------------------------
>
>                 Key: HBASE-16612
>                 URL: https://issues.apache.org/jira/browse/HBASE-16612
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Phil Yang
>            Assignee: Phil Yang
>            Priority: Minor
>
> We don't rely on enum ordinals in KeyValye.Type. We have own code in it. In 
> codeToType, we use a loop to find the Type which is not a good idea. We can 
> just use an arryay[256] to cache all types.



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

Reply via email to