hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r654169 - 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, 07 May 2008 16:58:14 GMT
Author: stack
Date: Wed May  7 09:58:10 2008
New Revision: 654169

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

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=654169&r1=654168&r2=654169&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed May  7 09:58:10 2008
@@ -31,6 +31,7 @@
    HBASE-607   MultiRegionTable.makeMultiRegionTable is not deterministic enough
                for regression tests
    HBASE-405   TIF and TOF use log4j directly rather than apache commons-logging
+   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/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=654169&r1=654168&r2=654169&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 May
 7 09:58:10 2008
@@ -860,7 +860,7 @@
             return midKey;
         }
       }
-      LOG.info("starting compaction on region " + getRegionName());
+      LOG.info("checking compaction on region " + getRegionName());
       long startTime = System.currentTimeMillis();
       doRegionCompactionPrep();
       for (HStore store: stores.values()) {
@@ -870,7 +870,7 @@
         }
       }
       doRegionCompactionCleanup();
-      LOG.info("compaction completed on region " + getRegionName() + " in " +
+      LOG.info("compaction checking completed on region " + getRegionName() + " in " +
         StringUtils.formatTimeDiff(System.currentTimeMillis(), startTime));
     } finally {
       synchronized (writestate) {

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=654169&r1=654168&r2=654169&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 May 
7 09:58:10 2008
@@ -26,6 +26,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
@@ -737,6 +738,21 @@
   //////////////////////////////////////////////////////////////////////////////
   // Compaction
   //////////////////////////////////////////////////////////////////////////////
+
+  /*
+   * @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;
+        }
+      }
+    }
+    return false;
+  }
   
   /**
    * Compact the back-HStores.  This method may take some time, so the calling 
@@ -763,30 +779,22 @@
       List<HStoreFile> filesToCompact = null;
       synchronized (storefiles) {
         filesToCompact = new ArrayList<HStoreFile>(this.storefiles.values());
-        if (filesToCompact.size() < 1) {
-          return checkSplit();
-        } else if (filesToCompact.size() == 1) {
-          if (!filesToCompact.get(0).isReference()) {
-            return checkSplit();
-          }
-        } else if (filesToCompact.size() < compactionThreshold) {
+        if (!hasReferences(filesToCompact) &&
+             filesToCompact.size() < compactionThreshold) {
           return checkSplit();
         }
-
         if (!fs.exists(compactionDir) && !fs.mkdirs(compactionDir)) {
           LOG.warn("Mkdir on " + compactionDir.toString() + " failed");
           return checkSplit();
         }
 
-        // Storefiles are keyed by sequence id. The oldest file comes first.
-        // We need to return out of here a List that has the newest file first.
-        Collections.reverse(filesToCompact);
-
         // The max-sequenceID in any of the to-be-compacted TreeMaps is the 
         // last key of storefiles.
-
         maxId = this.storefiles.lastKey().longValue();
       }
+      // Storefiles are keyed by sequence id. The oldest file comes first.
+      // We need to return out of here a List that has the newest file first.
+      Collections.reverse(filesToCompact);
 
       // Step through them, writing to the brand-new MapFile
       HStoreFile compactedOutputFile = new HStoreFile(conf, fs, 
@@ -1801,4 +1809,4 @@
       return copy;
     }
   }
-}
\ No newline at end of file
+}



Mime
View raw message