hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r829197 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/thrift/ src/test/org/apache/hadoop/hbase/ src/test/org/apache/hadoop/hbase/client/ src/test/org/apache/hadoop/hbase/regionserver/
Date Fri, 23 Oct 2009 20:02:39 GMT
Author: stack
Date: Fri Oct 23 20:02:14 2009
New Revision: 829197

URL: http://svn.apache.org/viewvc?rev=829197&view=rev
Log:
HBASE-1930 Put.setTimeStamp misleading (doesn't change timestamp on existing KeyValues, not
copied in copy constructor)

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestCase.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestScanMultipleVersions.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TimestampTestBase.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestGetRowVersions.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Fri Oct 23 20:02:14 2009
@@ -4,6 +4,9 @@
    HBASE-1822  Remove the deprecated APIs
    HBASE-1848  Fixup shell for HBASE-1822
    HBASE-1854  Remove the Region Historian
+   HBASE-1930  Put.setTimeStamp misleading (doesn't change timestamp on
+               existing KeyValues, not copied in copy constructor)
+               (Dave Latham via Stack)
 
   BUG FIXES
    HBASE-1791  Timeout in IndexRecordWriter (Bradford Stephens via Andrew

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java Fri Oct 23 20:02:14
2009
@@ -78,10 +78,21 @@
    * @param rowLock previously acquired row lock, or null
    */
   public Put(byte [] row, RowLock rowLock) {
+      this(row, HConstants.LATEST_TIMESTAMP, rowLock);
+  }
+  
+  /**
+   * Create a Put operation for the specified row, using a given timestamp, and an existing
row lock.
+   * @param row row key
+   * @param ts timestamp
+   * @param rowLock previously acquired row lock, or null
+   */
+  public Put(byte [] row, long ts, RowLock rowLock) {
     if(row == null || row.length > HConstants.MAX_ROW_LENGTH) {
       throw new IllegalArgumentException("Row key is invalid");
     }
     this.row = Arrays.copyOf(row, row.length);
+    this.timestamp = ts;
     if(rowLock != null) {
       this.lockId = rowLock.getLockId();
     }
@@ -92,13 +103,14 @@
    * @param putToCopy put to copy
    */
   public Put(Put putToCopy) {
-    this(putToCopy.getRow(), putToCopy.getRowLock());
+    this(putToCopy.getRow(), putToCopy.timestamp, putToCopy.getRowLock());
     this.familyMap = 
       new TreeMap<byte [], List<KeyValue>>(Bytes.BYTES_COMPARATOR);
     for(Map.Entry<byte [], List<KeyValue>> entry :
       putToCopy.getFamilyMap().entrySet()) {
       this.familyMap.put(entry.getKey(), entry.getValue());
     }
+    this.writeToWAL = putToCopy.writeToWAL;
   }
 
   /**
@@ -206,15 +218,6 @@
   }
   
   /**
-   * Method for setting the timestamp
-   * @param timestamp
-   */
-  public Put setTimeStamp(long timestamp) {
-    this.timestamp = timestamp;
-    return this;
-  }
-  
-  /**
    * @return the number of different families included in this put 
    */
   public int numFamilies() {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java Fri Oct 23
20:02:14 2009
@@ -441,8 +441,7 @@
       HTable table = null;
       try {
         table = getTable(tableName);
-        Put put = new Put(row);
-        put.setTimeStamp(timestamp);
+        Put put = new Put(row, timestamp, null);
 
         Delete delete = new Delete(row);
 
@@ -488,8 +487,7 @@
         byte[] row = batch.row;
         List<Mutation> mutations = batch.mutations;
         Delete delete = new Delete(row);
-        Put put = new Put(row);
-        put.setTimeStamp(timestamp);
+        Put put = new Put(row, timestamp, null);
         for (Mutation m : mutations) {
           byte[][] famAndQf = KeyValue.parseColumn(m.column);
           if (m.isDelete) {

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestCase.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestCase.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestCase.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestCase.java Fri Oct 23 20:02:14
2009
@@ -300,9 +300,11 @@
             break EXIT;
           }
           try {
-            Put put = new Put(t);
+            Put put;
             if(ts != -1) {
-              put.setTimeStamp(ts);
+              put = new Put(t, ts, null);
+            } else {
+              put = new Put(t);
             }
             try {
               StringBuilder sb = new StringBuilder();

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestScanMultipleVersions.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestScanMultipleVersions.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestScanMultipleVersions.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestScanMultipleVersions.java Fri
Oct 23 20:02:14 2009
@@ -71,8 +71,7 @@
         HRegion.createHRegion(this.INFOS[i], this.testDir, this.conf);
       // Insert data
       for (int j = 0; j < TIMESTAMPS.length; j++) {
-        Put put = new Put(ROWS[i]);
-        put.setTimeStamp(TIMESTAMPS[j]);
+        Put put = new Put(ROWS[i], TIMESTAMPS[j], null);
         put.add(HConstants.CATALOG_FAMILY, null, TIMESTAMPS[j], 
             Bytes.toBytes(TIMESTAMPS[j]));
         REGIONS[i].put(put);

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TimestampTestBase.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TimestampTestBase.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TimestampTestBase.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TimestampTestBase.java Fri Oct 23
20:02:14 2009
@@ -241,10 +241,7 @@
   public static void put(final Incommon loader, final byte [] bytes,
     final long ts)
   throws IOException {
-    Put put = new Put(ROW);
-    if(ts != HConstants.LATEST_TIMESTAMP) {
-      put.setTimeStamp(ts);
-    }
+    Put put = new Put(ROW, ts, null);
     put.add(FAMILY_NAME, QUALIFIER_NAME, bytes);
     loader.put(put);
   }

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestGetRowVersions.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestGetRowVersions.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestGetRowVersions.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestGetRowVersions.java Fri
Oct 23 20:02:14 2009
@@ -58,8 +58,7 @@
 
   /** @throws Exception */
   public void testGetRowMultipleVersions() throws Exception {
-    Put put = new Put(ROW);
-    put.setTimeStamp(TIMESTAMP1);
+    Put put = new Put(ROW, TIMESTAMP1, null);
     put.add(CONTENTS, CONTENTS, VALUE1);
     this.table.put(put);
     // Shut down and restart the HBase cluster
@@ -70,8 +69,7 @@
     // Make a new connection
     this.table = new HTable(conf, TABLE_NAME);
     // Overwrite previous value
-    put = new Put(ROW);
-    put.setTimeStamp(TIMESTAMP2);
+    put = new Put(ROW, TIMESTAMP2, null);
     put.add(CONTENTS, CONTENTS, VALUE2);
     this.table.put(put);
     // Now verify that getRow(row, column, latest) works

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java?rev=829197&r1=829196&r2=829197&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestScanner.java Fri
Oct 23 20:02:14 2009
@@ -205,8 +205,7 @@
       
       // Write information to the meta table
 
-      Put put = new Put(ROW_KEY);
-      put.setTimeStamp(System.currentTimeMillis());
+      Put put = new Put(ROW_KEY, System.currentTimeMillis(), null);
 
       ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
       DataOutputStream s = new DataOutputStream(byteStream);
@@ -236,8 +235,7 @@
  
       HServerAddress address = new HServerAddress("foo.bar.com:1234");
 
-      put = new Put(ROW_KEY);
-      put.setTimeStamp(System.currentTimeMillis());
+      put = new Put(ROW_KEY, System.currentTimeMillis(), null);
       put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
           Bytes.toBytes(address.toString()));
 
@@ -275,8 +273,7 @@
 
       address = new HServerAddress("bar.foo.com:4321");
       
-      put = new Put(ROW_KEY);
-      put.setTimeStamp(System.currentTimeMillis());
+      put = new Put(ROW_KEY, System.currentTimeMillis(), null);
 
       put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
           Bytes.toBytes(address.toString()));



Mime
View raw message