hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ronghai.ma (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-5388) Tuning HConnectionManager#getCachedLocation method
Date Sun, 12 Feb 2012 23:30:59 GMT

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

ronghai.ma commented on HBASE-5388:
-----------------------------------

I will upload the patch latter, many meetings,take a nap.
I reviewed the code, and changed some code.

{code}
//SoftValueSortedMap#lowerKey
public synchronized K lowerKey(K key) {
  checkReferences();    
  return ((TreeMap<K, SoftValue<K,V>>)this.internalMap).lowerKey(key);
}
//SoftValueSortedMap#getLower
public synchronized V getLower(K key) {
  checkReferences(); 
  Map.Entry<K,SoftValue<K,V>> entry = ((TreeMap<K, SoftValue<K,V>>)this.internalMap).lowerEntry(key);
  if(entry==null){
    return null;
  }
  SoftValue<K,V> value=entry.getValue();
  if(value==null){
    return null;
  } 
  if (value.get() == null) {
    this.internalMap.remove(key);
    return null;
  }
  return value.get();
}
{code}
{code}
//HConnectionManager#HConnectionImplementation#getCachedLocation
HRegionLocation rl = tableLocations.get(row);
if (rl != null) {
  return rl;
}
rl = tableLocations.getLower(row);
if(r1==null){
  return null;
}
byte[] endKey = rl.getRegionInfo().getEndKey();
if(Bytes.equals(endKey,HConstants.EMPTY_END_ROW)||
  KeyValue.getRowComparator(tableName).compareRows(endKey, 0, endKey.length, row, 0, row.length)
> 0){
  return rl;
}
{code}
                
> Tuning HConnectionManager#getCachedLocation method
> --------------------------------------------------
>
>                 Key: HBASE-5388
>                 URL: https://issues.apache.org/jira/browse/HBASE-5388
>             Project: HBase
>          Issue Type: Improvement
>    Affects Versions: 0.90.5
>            Reporter: ronghai.ma
>            Assignee: ronghai.ma
>              Labels: patch
>             Fix For: 0.94.0
>
>
> About 75% improvement in execution time.
> 1. Add the following method in SoftValueSortedMap:
> {code}
> public synchronized <K, V> Entry<K, V> lowerEntry(K key) {
>   return ((TreeMap) this.internalMap).lowerEntry(key);
> }
> {code}
> 2. Modify getCachedLocation:
> {code} 
> Map.Entry<byte[], HRegionLocation> tEntry = tableLocations.lowerEntry(row);
>   if (tEntry != null) {
>   HRegionLocation possibleRegion = tEntry.getValue();
>   //other code
> }
> {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

        

Mime
View raw message