hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r673524 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/java/org/apache/hadoop/hbase/regionserver/HStore.java
Date Wed, 02 Jul 2008 22:13:43 GMT
Author: jimk
Date: Wed Jul  2 15:13:41 2008
New Revision: 673524

URL: http://svn.apache.org/viewvc?rev=673524&view=rev
Log:
HBASE-712   midKey found compacting is the first, not necessarily the optimal

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=673524&r1=673523&r2=673524&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed Jul  2 15:13:41 2008
@@ -163,6 +163,7 @@
    HBASE-527   RegexpRowFilter does not work when there are columns from 
                multiple families (Clint Morgan via Jim Kellerman)
    HBASE-534   Double-assignment at SPLIT-time
+   HBASE-712   midKey found compacting is the first, not necessarily the optimal
    
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=673524&r1=673523&r2=673524&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Wed Jul
 2 15:13:41 2008
@@ -876,10 +876,12 @@
       LOG.info("starting compaction on region " + this);
       long startTime = System.currentTimeMillis();
       doRegionCompactionPrep();
+      long maxSize = -1;
       for (HStore store: stores.values()) {
-        final byte [] key = store.compact(force);
-        if (key != null && midKey == null) {
-          midKey = key;
+        final HStore.StoreSize size = store.compact(force);
+        if (size != null && size.getSize() > maxSize) {
+          maxSize = size.getSize();
+          midKey = size.getKey();
         }
       }
       doRegionCompactionCleanup();

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=673524&r1=673523&r2=673524&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java Wed Jul 
2 15:13:41 2008
@@ -854,7 +854,7 @@
    * @return mid key if a split is needed, null otherwise
    * @throws IOException
    */
-  byte [] compact(final boolean force) throws IOException {
+  StoreSize compact(final boolean force) throws IOException {
     synchronized (compactLock) {
       long maxId = -1;
       List<HStoreFile> filesToCompact = null;
@@ -1811,9 +1811,9 @@
   /**
    * Determines if HStore can be split
    * 
-   * @return midKey if store can be split, null otherwise
+   * @return a StoreSize if store can be split, null otherwise
    */
-  byte [] checkSplit() {
+  StoreSize checkSplit() {
     if (this.storefiles.size() <= 0) {
       return null;
     }
@@ -1865,7 +1865,7 @@
             Bytes.equals(mk.getRow(), lastKey.getRow())) {
           return null;
         }
-        return mk.getRow();
+        return new StoreSize(maxSize, mk.getRow());
       }
     } catch(IOException e) {
       LOG.warn("Failed getting store size for " + this.storeNameStr, e);
@@ -1931,4 +1931,22 @@
       return copy;
     }
   }
+  
+  class StoreSize {
+    private final long size;
+    private final byte[] key;
+    StoreSize(long size, byte[] key) {
+      this.size = size;
+      this.key = new byte[key.length];
+      System.arraycopy(key, 0, this.key, 0, key.length);
+    }
+    /* @return the size */
+    long getSize() {
+      return size;
+    }
+    /* @return the key */
+    byte[] getKey() {
+      return key;
+    }
+  }
 }
\ No newline at end of file



Mime
View raw message