hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r658419 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/regionserver/ src/test/org/apache/hadoop/hbase/regionserver/
Date Tue, 20 May 2008 20:40:47 GMT
Author: stack
Date: Tue May 20 13:40:47 2008
New Revision: 658419

URL: http://svn.apache.org/viewvc?rev=658419&view=rev
Log:
HBASE-621 Make MAX_VERSIONS work like TTL: In scans and gets, check MAX_VERSIONs setting and
return that many only rather than wait on compaction

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=658419&r1=658418&r2=658419&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue May 20 13:40:47 2008
@@ -40,6 +40,9 @@
                and HConnectionManager (Jean-Daniel Cryans via Stack)
    HBASE-23    UI listing regions should be sorted by address and show additional
                region state (Jean-Daniel Cryans via Stack)
+   HBASE-621   Make MAX_VERSIONS work like TTL: In scans and gets, check
+               MAX_VERSIONs setting and return that many only rather than wait on
+               compaction (Jean-Daniel Cryans via Stack)
 
 Release 0.1.2 - 05/13/2008
    

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java?rev=658419&r1=658418&r2=658419&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java Tue May 20 13:40:47
2008
@@ -196,7 +196,7 @@
   /**
    * Define for 'return-all-versions'.
    */
-  static final int ALL_VERSIONS = -1;
+  static final int ALL_VERSIONS = Integer.MAX_VALUE;
   
   /**
    * Unlimited time-to-live.

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=658419&r1=658418&r2=658419&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 Tue May 20
13:40:47 2008
@@ -1230,7 +1230,7 @@
    * Get the value for the indicated HStoreKey.  Grab the target value and the 
    * previous 'numVersions-1' values, as well.
    *
-   * If 'numVersions' is negative, the method returns all available versions.
+   * Use {@link HConstants.ALL_VERSIONS} to retrieve all versions.
    * @param key
    * @param numVersions Number of versions to fetch.  Must be > 0.
    * @return values for the specified versions
@@ -1246,7 +1246,7 @@
     try {
       // Check the memcache
       List<Cell> results = this.memcache.get(key, numVersions);
-      // If we got sufficient versions from memcache, return.
+      // If we got sufficient versions from memcache, return. 
       if (results.size() == numVersions) {
         return results.toArray(new Cell[results.size()]);
       }
@@ -1323,9 +1323,18 @@
     }
   }
   
+  /**
+   * Small method to check if we are over the max number of versions
+   * or we acheived this family max versions. 
+   * The later happens when we have the situation described in HBASE-621.
+   * @param numVersions
+   * @param results
+   * @return 
+   */
   private boolean hasEnoughVersions(final int numVersions,
       final List<Cell> results) {
-    return numVersions > 0 && results.size() >= numVersions;
+    return (results.size() >= numVersions || results.size() >= family
+            .getMaxVersions());
   }
 
   /**
@@ -1345,8 +1354,9 @@
    */
   List<HStoreKey> getKeys(final HStoreKey origin, final int versions)
   throws IOException {
+      
     List<HStoreKey> keys = this.memcache.getKeys(origin, versions);
-    if (versions != ALL_VERSIONS && keys.size() >= versions) {
+    if (keys.size() >= versions) {
       return keys;
     }
     
@@ -1391,7 +1401,7 @@
                   }
 
                   // if we've collected enough versions, then exit the loop.
-                  if (versions != ALL_VERSIONS && keys.size() >= versions) {
+                  if (keys.size() >= versions) {
                     break;
                   }
                 }

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java?rev=658419&r1=658418&r2=658419&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Memcache.java Tue May
20 13:40:47 2008
@@ -610,7 +610,7 @@
             LOG.debug("internalGetKeys: " + key + ": expired, skipped");
           }
         }
-        if (versions != HConstants.ALL_VERSIONS && result.size() >= versions)
{
+        if (result.size() >= versions) {
           // We have enough results.  Return.
           break;
         }

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java?rev=658419&r1=658418&r2=658419&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java Tue
May 20 13:40:47 2008
@@ -101,8 +101,8 @@
     addContent(new HRegionIncommon(r), Bytes.toString(COLUMN_FAMILY));
     Cell[] cellValues = 
       r.get(STARTROW, COLUMN_FAMILY_TEXT, 100 /*Too many*/);
-    // Assert that I can get > 5 versions (Should be at least 5 in there).
-    assertTrue(cellValues.length >= 5);
+    // Assert that I can get 3 versions since it is the max I should get
+    assertTrue(cellValues.length == 3);
     r.flushcache();
     r.compactStores();
     // Now assert that there are 4 versions of a record only: thats the



Mime
View raw message