hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "samar (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HBASE-5110) code enhancement - remove unnecessary if-checks in every loop in HLog class
Date Fri, 31 May 2013 11:52:20 GMT

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

samar updated HBASE-5110:
-------------------------

    Status: Patch Available  (was: Open)
    
> code enhancement - remove unnecessary if-checks in every loop in HLog class
> ---------------------------------------------------------------------------
>
>                 Key: HBASE-5110
>                 URL: https://issues.apache.org/jira/browse/HBASE-5110
>             Project: HBase
>          Issue Type: Improvement
>          Components: wal
>    Affects Versions: 0.92.0, 0.90.4, 0.90.2, 0.90.1
>            Reporter: Mikael Sitruk
>            Priority: Minor
>         Attachments: HBASE-5110_1.patch
>
>
> The HLog class (method findMemstoresWithEditsEqualOrOlderThan) has unnecessary if check
in a loop.
>  static byte [][] findMemstoresWithEditsEqualOrOlderThan(final long oldestWALseqid,
>       final Map<byte [], Long> regionsToSeqids) {
>     //  This method is static so it can be unit tested the easier.
>     List<byte []> regions = null;
>     for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
>       if (e.getValue().longValue() <= oldestWALseqid) {
>         if (regions == null) regions = new ArrayList<byte []>();
>         regions.add(e.getKey());
>       }
>     }
>     return regions == null?
>       null: regions.toArray(new byte [][] {HConstants.EMPTY_BYTE_ARRAY});
>   }
> The following change is suggested
>   static byte [][] findMemstoresWithEditsEqualOrOlderThan(final long oldestWALseqid,
>       final Map<byte [], Long> regionsToSeqids) {
>     //  This method is static so it can be unit tested the easier.
>     List<byte []> regions = new ArrayList<byte []>();
>     for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
>       if (e.getValue().longValue() <= oldestWALseqid) {
>         regions.add(e.getKey());
>       }
>     }
>     return regions.size() == 0?
>       null: regions.toArray(new byte [][] {HConstants.EMPTY_BYTE_ARRAY});
>   }

--
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

Mime
View raw message