hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r939030 - in /hadoop/hbase/trunk: ./ core/src/main/java/org/apache/hadoop/hbase/regionserver/
Date Wed, 28 Apr 2010 17:52:43 GMT
Author: jdcryans
Date: Wed Apr 28 17:52:43 2010
New Revision: 939030

URL: http://svn.apache.org/viewvc?rev=939030&view=rev
Log:
HBASE-2496  Less ArrayList churn on the scan path

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ColumnCount.java
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
    hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=939030&r1=939029&r2=939030&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed Apr 28 17:52:43 2010
@@ -537,6 +537,7 @@ Release 0.21.0 - Unreleased
                (Todd Lipcon via Stack)
    HBASE-2393  ThriftServer instantiates a new HTable per request
                (Bogdan DRAGU via Stack)
+   HBASE-2496  Less ArrayList churn on the scan path
 
   NEW FEATURES
    HBASE-1961  HBase EC2 scripts

Modified: hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ColumnCount.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ColumnCount.java?rev=939030&r1=939029&r2=939030&view=diff
==============================================================================
--- hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ColumnCount.java
(original)
+++ hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ColumnCount.java
Wed Apr 28 17:52:43 2010
@@ -25,9 +25,9 @@ package org.apache.hadoop.hbase.regionse
  * NOT thread-safe because it is not used in a multi-threaded context, yet.
  */
 public class ColumnCount {
-  private byte [] bytes;
-  private int offset;
-  private int length;
+  private final byte [] bytes;
+  private final int offset;
+  private final int length;
   private int count;
   
   /**
@@ -97,6 +97,15 @@ public class ColumnCount {
   public int increment() {
     return ++count;
   }
+
+  /**
+   * Set the current count to a new count
+   * @param count new count to set
+   */
+  public void setCount(int count) {
+    this.count = count;
+  }  
+
   
   /**
    * Check to see if needed to fetch more versions

Modified: hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java?rev=939030&r1=939029&r2=939030&view=diff
==============================================================================
--- hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
(original)
+++ hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
Wed Apr 28 17:52:43 2010
@@ -46,11 +46,11 @@ import org.apache.hadoop.hbase.util.Byte
  */
 public class ExplicitColumnTracker implements ColumnTracker {
 
-  private int maxVersions;
-  private List<ColumnCount> columns;
+  private final int maxVersions;
+  private final List<ColumnCount> columns;
+  private final List<ColumnCount> columnsToReuse;
   private int index;
   private ColumnCount column;
-  private NavigableSet<byte[]> origColumns;
   
   /**
    * Default constructor.
@@ -59,7 +59,11 @@ public class ExplicitColumnTracker imple
    */
   public ExplicitColumnTracker(NavigableSet<byte[]> columns, int maxVersions) {
     this.maxVersions = maxVersions;
-    this.origColumns = columns;
+    this.columns = new ArrayList<ColumnCount>(columns.size());
+    this.columnsToReuse = new ArrayList<ColumnCount>(columns.size());
+    for(byte [] column : columns) {
+      this.columnsToReuse.add(new ColumnCount(column,maxVersions));
+    }
     reset();
   }
   
@@ -147,15 +151,16 @@ public class ExplicitColumnTracker imple
 
   // Called between every row.
   public void reset() {
-    buildColumnList(this.origColumns);
+    buildColumnList();
     this.index = 0;
     this.column = this.columns.get(this.index);
   }
 
-  private void buildColumnList(NavigableSet<byte[]> columns) {
-    this.columns = new ArrayList<ColumnCount>(columns.size());
-    for(byte [] column : columns) {
-      this.columns.add(new ColumnCount(column,maxVersions));
+  private void buildColumnList() {
+    this.columns.clear();
+    this.columns.addAll(this.columnsToReuse);
+    for(ColumnCount col : this.columns) {
+      col.setCount(this.maxVersions);
     }
   }
 }

Modified: hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=939030&r1=939029&r2=939030&view=diff
==============================================================================
--- hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Wed Apr 28 17:52:43 2010
@@ -1815,12 +1815,12 @@ public class HRegionServer implements HC
         throw e;
       }
       this.leases.renewLease(scannerName);
-      List<Result> results = new ArrayList<Result>();
+      List<Result> results = new ArrayList<Result>(nbRows);
       long currentScanResultSize = 0;
+      List<KeyValue> values = new ArrayList<KeyValue>();
       for (int i = 0; i < nbRows && currentScanResultSize < maxScannerResultSize;
i++) {
         requestCount.incrementAndGet();
         // Collect values to be returned here
-        List<KeyValue> values = new ArrayList<KeyValue>();
         boolean moreRows = s.next(values);
         if (!values.isEmpty()) {
           for (KeyValue kv : values) {
@@ -1831,6 +1831,7 @@ public class HRegionServer implements HC
         if (!moreRows) {
           break;
         }
+        values.clear();
       }
       // Below is an ugly hack where we cast the InternalScanner to be a
       // HRegion.RegionScanner.  The alternative is to change InternalScanner



Mime
View raw message