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

Nick Dimiduk commented on HBASE-6493:
-------------------------------------

Grep on trunk reveals the following:

{noformat}
$ grep -rin 'Hash.*<byte\[\]>' *
hbase-common/src/main/java/org/apache/hadoop/hbase/util/test/RedundantKVGenerator.java:192:
        new HashMap<Integer, List<byte[]>>();
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java:3287:
        columnFamilies = new HashSet<byte[]>();
hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java:481:
    HashMap<byte[], Set<byte[]>> familyMap = 
Maps.newHashMapWithExpectedSize(families.size());
hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java:1197:
            HashMap<byte[], Set<byte[]>> familyMap = 
Maps.newHashMapWithExpectedSize(1);
{noformat}

- The {{RedundantKVGenerator}} hit is a false-positive.
- In {{HRegionServer}}, {{columnFamilies}} is normally the keySet produced by 
the store, backed by an instance of {{ConcurrentSkipListMap}} which is 
constructed to use {{Bytes.BYTES_RAWCOMPARATOR}}. To preserve identical 
semantics, this line should be updated to use, say, a {{TreeSet}} with the same 
comparator.
- {{AccessController:481}} eventually passes the {{HashMap}} down to the 
{{AuthResult}} constructor, which iterates its content to generate a String. No 
comparisons here.
- Likewise with {{AccessController:1197}}.

I'll create a patch to replace {{columnFamilies}} with a {{TreeSet}}.
                
> HashSet of byte array is being used in couple of places
> -------------------------------------------------------
>
>                 Key: HBASE-6493
>                 URL: https://issues.apache.org/jira/browse/HBASE-6493
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Shrijeet Paliwal
>            Priority: Minor
>
> While working on a jira I realized I had made a mistake of making a HashSet 
> of byte array. 
> Then out of curiosity I checked if we do same any where else in code base. I 
> came with following files. 
> # /src/main/java/org/apache/hadoop/hbase/mapreduce/RowCounter.java:    
> Set<byte []> qualifiers = new HashSet<byte[]>();
> # /src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java:     
>    columnFamilies = new HashSet<byte[]>();
> # 
> /src/test/java/org/apache/hadoop/hbase/filter/TestFirstKeyValueMatchingQualifiersFilter.java:
>     Set<byte[]> quals = new HashSet<byte[]>();
> # 
> /src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestSchemaMetrics.java:
>     Set<byte[]> families = new HashSet<byte[]>();
> (1) and (3) are mine and I will fix them (not yet committed). Quoting the 
> exact reference from (2) below :
> {code}
>  @Override                                                                    
>  
>   public GetStoreFileResponse getStoreFile(final RpcController controller,    
>       
>       final GetStoreFileRequest request) throws ServiceException {            
>   
>     try {                                                                     
>   
>       HRegion region = getRegion(request.getRegion());                        
>   
>       requestCount.incrementAndGet();                                         
>   
>       Set<byte[]> columnFamilies = null;                                      
>   
>       if (request.getFamilyCount() == 0) {                                    
>   
>         columnFamilies = region.getStores().keySet();                         
>   
>       } else {                                                                
>   
>         columnFamilies = new HashSet<byte[]>();                               
>   
>         for (ByteString cf: request.getFamilyList()) {                        
>   
>           columnFamilies.add(cf.toByteArray());                               
>   
>         }                                                                     
>   
>       }  
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to