You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Swaroopa Kadam (Jira)" <ji...@apache.org> on 2021/03/19 01:18:00 UTC

[jira] [Assigned] (HBASE-25576) Should not use HashMap (ConcurrentHashMap) or HashSet when using byte[] as a key of Map or an element of Set

     [ https://issues.apache.org/jira/browse/HBASE-25576?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Swaroopa Kadam reassigned HBASE-25576:
--------------------------------------

    Assignee: Swaroopa Kadam

> Should not use HashMap (ConcurrentHashMap) or HashSet when using byte[] as a key of Map or an element of Set
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-25576
>                 URL: https://issues.apache.org/jira/browse/HBASE-25576
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Toshihiro Suzuki
>            Assignee: Swaroopa Kadam
>            Priority: Major
>              Labels: beginner
>
> I sometimes face the code using HashMap (ConcurrentHashMap) or HashSet when using byte[] as a key of Map or an element of Set in the HBase code, which could cause very confusing bugs.
> We should use TreeMap (ConcurrentSkipListMap) or TreeSet (ConcurrentSkipListSet) with Bytes.BYTES_COMPARATOR when using byte[] as a key of Map or an element of Set as follows:
> {code}
> Map<byte[], String> map1 = new TreeMap<>(Bytes.BYTES_COMPARATOR);
> Map<byte[], String> map2 = new ConcurrentSkipListMap<>(Bytes.BYTES_COMPARATOR);
> Set<byte[]> set1 = new TreeSet<>(Bytes.BYTES_COMPARATOR);
> Set<byte[]> set2 = new ConcurrentSkipListSet<>(Bytes.BYTES_COMPARATOR);
> {code}
> We should fix the existing ones in this Jira.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)