hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r654163 - in /hadoop/hbase/branches/0.1: CHANGES.txt src/java/org/apache/hadoop/hbase/HRegion.java src/java/org/apache/hadoop/hbase/HStore.java
Date Wed, 07 May 2008 16:38:50 GMT
Author: stack
Date: Wed May  7 09:38:46 2008
New Revision: 654163

URL: http://svn.apache.org/viewvc?rev=654163&view=rev
Log:
HBASE-618 We always compact if 2 files, regardless of the compaction threshold setting

Modified:
    hadoop/hbase/branches/0.1/CHANGES.txt
    hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java
    hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HStore.java

Modified: hadoop/hbase/branches/0.1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/CHANGES.txt?rev=654163&r1=654162&r2=654163&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.1/CHANGES.txt Wed May  7 09:38:46 2008
@@ -31,6 +31,7 @@
    HBASE-607   MultiRegionTable.makeMultiRegionTable is not deterministic enough
                for regression tests
    HBASE-478   offlining of table does not run reliably
+   HBASE-618   We always compact if 2 files, regardless of the compaction threshold setting
    
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java?rev=654163&r1=654162&r2=654163&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java (original)
+++ hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HRegion.java Wed May  7 09:38:46
2008
@@ -932,7 +932,7 @@
         }
       }
       long startTime = System.currentTimeMillis();
-      LOG.info("starting compaction on region " + getRegionName());
+      LOG.info("checking compaction on region " + getRegionName());
       boolean status = true;
       doRegionCompactionPrep();
       for (HStore store : stores.values()) {
@@ -942,7 +942,7 @@
       }
       doRegionCompactionCleanup();
 
-      LOG.info("compaction completed on region " + getRegionName() + " in " +
+      LOG.info("checking completed on region " + getRegionName() + " in " +
         StringUtils.formatTimeDiff(System.currentTimeMillis(), startTime));
       return status;
       

Modified: hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HStore.java?rev=654163&r1=654162&r2=654163&view=diff
==============================================================================
--- hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HStore.java (original)
+++ hadoop/hbase/branches/0.1/src/java/org/apache/hadoop/hbase/HStore.java Wed May  7 09:38:46
2008
@@ -23,6 +23,7 @@
 import java.io.UnsupportedEncodingException;
 import java.rmi.UnexpectedException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -1323,8 +1324,17 @@
    * @return True if this store has references.
    */
   private boolean hasReferences() {
-    if (this.storefiles != null) {
-      for (HStoreFile hsf: this.storefiles.values()) {
+    return this.storefiles != null && this.storefiles.size() > 0 &&
+      hasReferences(this.storefiles.values());
+  }
+  
+  /*
+   * @param files
+   * @return True if any of the files in <code>files</code> are References.
+   */
+  private boolean hasReferences(Collection<HStoreFile> files) {
+    if (files != null && files.size() > 0) {
+      for (HStoreFile hsf: files) {
         if (hsf.isReference()) {
           return true;
         }
@@ -1361,15 +1371,11 @@
       if (filesToCompact.size() == 0) {
         return true;
       }
-      Collections.reverse(filesToCompact);
-      if (filesToCompact.size() < 1 ||
-        (filesToCompact.size() == 1 && !filesToCompact.get(0).isReference())) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("nothing to compact for " + this.storeName);
-        }
+      if (!hasReferences(filesToCompact) &&
+          filesToCompact.size() < compactionThreshold) {
         return false;
       }
-
+      Collections.reverse(filesToCompact);
       if (!fs.exists(compactionDir) && !fs.mkdirs(compactionDir)) {
         LOG.warn("Mkdir on " + compactionDir.toString() + " failed");
         return false;



Mime
View raw message