You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Shrijeet Paliwal (JIRA)" <ji...@apache.org> on 2012/08/02 00:44:02 UTC

[jira] [Created] (HBASE-6493) HashSet of byte array is being used in couple of places

Shrijeet Paliwal created HBASE-6493:
---------------------------------------

             Summary: 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6493) HashSet of byte array is being used in couple of places

Posted by "Lars Hofhansl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13427064#comment-13427064 ] 

Lars Hofhansl commented on HBASE-6493:
--------------------------------------

I meant the one in RegionServer is definitely a bug.
And generally we could add a build check for that (i.e. just grep for HashSet<byte[]> and HashMap<byte[]>

                
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6493) HashSet of byte array is being used in couple of places

Posted by "Lars Hofhansl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13427072#comment-13427072 ] 

Lars Hofhansl commented on HBASE-6493:
--------------------------------------

Interestingly there is just one such occurrence in 0.94 (TestSchemaMetrics.java)
                
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6493) HashSet of byte array is being used in couple of places

Posted by "Lars Hofhansl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13427022#comment-13427022 ] 

Lars Hofhansl commented on HBASE-6493:
--------------------------------------

The one in RegioServer is curious. We should add a static check for this.
It is not necessarily incorrect if the byte[] is an an identity.
                
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (HBASE-6493) HashSet of byte array is being used in couple of places

Posted by "Shrijeet Paliwal (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HBASE-6493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13427031#comment-13427031 ] 

Shrijeet Paliwal commented on HBASE-6493:
-----------------------------------------

Lars, 
{quote}
The one in RegioServer is curious. We should add a static check for this.
{quote}
Did not understand. Do you mean a check during compile time?
{quote}
It is not necessarily incorrect if the byte[] is an an identity.
{quote}
Agree.
                
> 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira