hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r769577 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/HColumnDescriptor.java src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java src/java/org/apache/hadoop/hbase/regionserver/Store.java
Date Tue, 28 Apr 2009 22:35:08 GMT
Author: stack
Date: Tue Apr 28 22:35:07 2009
New Revision: 769577

URL: http://svn.apache.org/viewvc?rev=769577&view=rev
Log:
HBASE-1355 [performance] Cache family maxversions; we were calculating on each access

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=769577&r1=769576&r2=769577&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Apr 28 22:35:07 2009
@@ -90,6 +90,8 @@
    HBASE-1287  Partitioner class not used in TableMapReduceUtil.initTableReduceJob()
                (Lars George and Billy Pearson via Stack)
    HBASE-1320  hbase-1234 broke filter tests
+   HBASE-1355  [performance] Cache family maxversions; we were calculating on
+               each access
 
   IMPROVEMENTS
    HBASE-1089  Add count of regions on filesystem to master UI; add percentage

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java?rev=769577&r1=769576&r2=769577&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HColumnDescriptor.java Tue Apr 28
22:35:07 2009
@@ -145,6 +145,11 @@
   protected Map<ImmutableBytesWritable,ImmutableBytesWritable> values =
     new HashMap<ImmutableBytesWritable,ImmutableBytesWritable>();
 
+  /*
+   * Cache the max versions rather than calculate it every time.
+   */
+  private int cachedMaxVersions = -1;
+
   /**
    * Default constructor. Must be present for Writable.
    */
@@ -370,11 +375,13 @@
   
   /** @return maximum number of versions */
   @TOJSON
-  public int getMaxVersions() {
-    String value = getValue(HConstants.VERSIONS);
-    if (value != null)
-      return Integer.valueOf(value).intValue();
-    return DEFAULT_VERSIONS;
+  public synchronized int getMaxVersions() {
+    if (this.cachedMaxVersions == -1) {
+      String value = getValue(HConstants.VERSIONS);
+      this.cachedMaxVersions = (value != null)?
+        Integer.valueOf(value).intValue(): DEFAULT_VERSIONS;
+    }
+    return this.cachedMaxVersions;
   }
 
   /**

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java?rev=769577&r1=769576&r2=769577&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Tue Apr 28 22:35:07
2009
@@ -632,11 +632,13 @@
         Object value = method.invoke(instance, call.getParameters());
         int processingTime = (int) (System.currentTimeMillis() - startTime);
         int qTime = (int) (startTime-receivedTime);
-        LOG.debug("Served: " + call.getMethodName() +
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Served: " + call.getMethodName() +
             " queueTime= " + qTime +
             " procesingTime= " + processingTime);
-        rpcMetrics.rpcQueueTime.inc(qTime);
-        rpcMetrics.rpcProcessingTime.inc(processingTime);
+          rpcMetrics.rpcQueueTime.inc(qTime);
+          rpcMetrics.rpcProcessingTime.inc(processingTime);
+        }
 
 	MetricsTimeVaryingRate m = rpcMetrics.metricsList.get(call.getMethodName());
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=769577&r1=769576&r2=769577&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java Tue Apr 28
22:35:07 2009
@@ -1139,9 +1139,9 @@
       throw new IllegalArgumentException("Number of versions must be > 0");
     }
     // Make sure we do not return more than maximum versions for this store.
-    return wantedVersions > this.family.getMaxVersions() &&
-        wantedVersions != HConstants.ALL_VERSIONS?
-      this.family.getMaxVersions(): wantedVersions;
+    int maxVersions = this.family.getMaxVersions();
+    return wantedVersions > maxVersions &&
+      wantedVersions != HConstants.ALL_VERSIONS? maxVersions: wantedVersions;
   }
   
   /**



Mime
View raw message