You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/04/13 20:02:02 UTC

svn commit: r764545 - in /hadoop/hbase/trunk: CHANGES.txt src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java

Author: stack
Date: Mon Apr 13 18:02:01 2009
New Revision: 764545

URL: http://svn.apache.org/viewvc?rev=764545&view=rev
Log:
HBASE-1324 hbase-1234 broke testget2 unit test (and broke the build)

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=764545&r1=764544&r2=764545&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Mon Apr 13 18:02:01 2009
@@ -75,6 +75,7 @@
                names in links (Lars George via Stack)
    HBASE-1310  Off by one error in Bytes.vintToBytes
    HBASE-1202  getRow does not always work when specifying number of versions
+   HBASE-1324  hbase-1234 broke testget2 unit test (and broke the build)
 
   IMPROVEMENTS
    HBASE-1089  Add count of regions on filesystem to master UI; add percentage

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java?rev=764545&r1=764544&r2=764545&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestGet2.java Mon Apr 13 18:02:01 2009
@@ -63,56 +63,6 @@
   }
 
 
-  /**
-   * Test for HBASE-808 and HBASE-809.
-   * @throws Exception
-   */
-  public void testMaxVersionsAndDeleting() throws Exception {
-    HRegion region = null;
-    try {
-      HTableDescriptor htd = createTableDescriptor(getName());
-      region = createNewHRegion(htd, null, null);
-      
-      byte [] column = COLUMNS[0];
-      for (int i = 0; i < 100; i++) {
-        addToRow(region, T00, column, i, T00.getBytes());
-      }
-      checkVersions(region, T00, column);
-      // Flush and retry.
-      region.flushcache();
-      checkVersions(region, T00, column);
-      
-      // Now delete all then retry
-      region.deleteAll(Bytes.toBytes(T00), System.currentTimeMillis(), null);
-      Cell [] cells = Cell.createSingleCellArray(region.get(Bytes.toBytes(T00), column, -1,
-        HColumnDescriptor.DEFAULT_VERSIONS));
-      assertTrue(cells == null);
-      region.flushcache();
-      cells = Cell.createSingleCellArray(region.get(Bytes.toBytes(T00), column, -1,
-          HColumnDescriptor.DEFAULT_VERSIONS));
-      assertTrue(cells == null);
-      
-      // Now add back the rows
-      for (int i = 0; i < 100; i++) {
-        addToRow(region, T00, column, i, T00.getBytes());
-      }
-      // Run same verifications.
-      checkVersions(region, T00, column);
-      // Flush and retry.
-      region.flushcache();
-      checkVersions(region, T00, column);
-    } finally {
-      if (region != null) {
-        try {
-          region.close();
-        } catch (Exception e) {
-          e.printStackTrace();
-        }
-        region.getLog().closeAndDelete();
-      }
-    }
-  }
-
   public void testGetFullMultiMapfile() throws IOException {
     HRegion region = null;
     BatchUpdate batchUpdate = null;
@@ -135,8 +85,10 @@
       region.flushcache();
 
       // assert that getFull gives us the older value
-      results = region.getFull(row, (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
-      assertEquals("olderValue", new String(results.get(COLUMNS[0]).getValue()));
+      results = region.getFull(row, (NavigableSet<byte []>)null,
+        LATEST_TIMESTAMP, 1, null);
+      assertEquals("olderValue",
+        new String(results.get(COLUMNS[0]).getValue()));
       
       // write a new value for the cell
       batchUpdate = new BatchUpdate(row);
@@ -147,7 +99,8 @@
       region.flushcache();
       
       // assert that getFull gives us the later value
-      results = region.getFull(row, (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
+      results = region.getFull(row, (NavigableSet<byte []>)null,
+        LATEST_TIMESTAMP, 1, null);
       assertEquals("newerValue", new String(results.get(COLUMNS[0]).getValue()));
      
       //
@@ -157,9 +110,11 @@
       byte [] cell1 = Bytes.toBytes(Bytes.toString(COLUMNS[0]) + "a");
       byte [] cell2 = Bytes.toBytes(Bytes.toString(COLUMNS[0]) + "b");
       byte [] cell3 = Bytes.toBytes(Bytes.toString(COLUMNS[0]) + "c");
+
+      long now = System.currentTimeMillis();
       
       // write some data at two columns
-      batchUpdate = new BatchUpdate(row2);
+      batchUpdate = new BatchUpdate(row2, now);
       batchUpdate.put(cell1, "column0 value".getBytes());
       batchUpdate.put(cell2, "column1 value".getBytes());
       region.batchUpdate(batchUpdate, null);
@@ -168,22 +123,24 @@
       region.flushcache();
       
       // assert i get both columns
-      results = region.getFull(row2, (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
+      results = region.getFull(row2,
+        (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
       assertEquals("Should have two columns in the results map", 2, results.size());
       assertEquals("column0 value", new String(results.get(cell1).getValue()));
       assertEquals("column1 value", new String(results.get(cell2).getValue()));
       
       // write a delete for the first column
-      batchUpdate = new BatchUpdate(row2);
+      batchUpdate = new BatchUpdate(row2, now);
       batchUpdate.delete(cell1);
-      batchUpdate.put(cell2, "column1 new value".getBytes());      
+      batchUpdate.put(cell2, "column1 new value".getBytes());
       region.batchUpdate(batchUpdate, null);
             
       // flush
       region.flushcache(); 
       
       // assert i get the second column only
-      results = region.getFull(row2, (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
+      results = region.getFull(row2, (NavigableSet<byte []>)null,
+        LATEST_TIMESTAMP, 1, null);
       System.out.println(Bytes.toString(results.keySet().iterator().next()));
       assertEquals("Should have one column in the results map", 1, results.size());
       assertNull("column0 value", results.get(cell1));
@@ -192,11 +149,11 @@
       //
       // Include a delete and value from the memcache in the mix
       //
-      batchUpdate = new BatchUpdate(row2);
+      batchUpdate = new BatchUpdate(row2, now);
       batchUpdate.delete(cell2);
       batchUpdate.put(cell3, "column3 value!".getBytes());
       region.batchUpdate(batchUpdate, null);
-      
+
       // assert i get the third column only
       results = region.getFull(row2, (NavigableSet<byte []>)null, LATEST_TIMESTAMP, 1, null);
       assertEquals("Should have one column in the results map", 1, results.size());
@@ -216,6 +173,56 @@
     }  
   }
 
+  /**
+   * Test for HBASE-808 and HBASE-809.
+   * @throws Exception
+   */
+  public void testMaxVersionsAndDeleting() throws Exception {
+    HRegion region = null;
+    try {
+      HTableDescriptor htd = createTableDescriptor(getName());
+      region = createNewHRegion(htd, null, null);
+      
+      byte [] column = COLUMNS[0];
+      for (int i = 0; i < 100; i++) {
+        addToRow(region, T00, column, i, T00.getBytes());
+      }
+      checkVersions(region, T00, column);
+      // Flush and retry.
+      region.flushcache();
+      checkVersions(region, T00, column);
+      
+      // Now delete all then retry
+      region.deleteAll(Bytes.toBytes(T00), System.currentTimeMillis(), null);
+      Cell [] cells = Cell.createSingleCellArray(region.get(Bytes.toBytes(T00), column, -1,
+        HColumnDescriptor.DEFAULT_VERSIONS));
+      assertTrue(cells == null);
+      region.flushcache();
+      cells = Cell.createSingleCellArray(region.get(Bytes.toBytes(T00), column, -1,
+          HColumnDescriptor.DEFAULT_VERSIONS));
+      assertTrue(cells == null);
+      
+      // Now add back the rows
+      for (int i = 0; i < 100; i++) {
+        addToRow(region, T00, column, i, T00.getBytes());
+      }
+      // Run same verifications.
+      checkVersions(region, T00, column);
+      // Flush and retry.
+      region.flushcache();
+      checkVersions(region, T00, column);
+    } finally {
+      if (region != null) {
+        try {
+          region.close();
+        } catch (Exception e) {
+          e.printStackTrace();
+        }
+        region.getLog().closeAndDelete();
+      }
+    }
+  }
+
   /** For HBASE-694 
    * @throws IOException
    */