From de546af64619208349b8290aca94adb56abb97d0 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Cryans Date: Wed, 26 Aug 2009 00:03:42 +0000 Subject: [PATCH] HBASE-1792 [Regression] Cannot save timestamp in the future HBASE-1793 [Regression] HTable.get/getRow with a ts is broken git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@807855 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../org/apache/hadoop/hbase/client/HTable.java | 15 ++++++++------- .../apache/hadoop/hbase/regionserver/HRegion.java | 9 +++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index cc1297d739b..abaafd62a34 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -6,6 +6,8 @@ Release 0.21.0 - Unreleased HBASE-1791 Timeout in IndexRecordWriter (Bradford Stephens via Andrew Purtell) HBASE-1737 Regions unbalanced when adding new node (recommit) + HBASE-1792 [Regression] Cannot save timestamp in the future + HBASE-1793 [Regression] HTable.get/getRow with a ts is broken IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/java/org/apache/hadoop/hbase/client/HTable.java b/src/java/org/apache/hadoop/hbase/client/HTable.java index 1ac7ceca7ef..72b56c47e35 100644 --- a/src/java/org/apache/hadoop/hbase/client/HTable.java +++ b/src/java/org/apache/hadoop/hbase/client/HTable.java @@ -796,9 +796,8 @@ public class HTable implements HTableInterface { g.addColumn(fq[0], fq[1]); } g.setMaxVersions(numVersions); - if (timestamp != HConstants.LATEST_TIMESTAMP) { - g.setTimeStamp(timestamp); - } + g.setTimeRange(0, + timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1); Result r = get(g); return r == null || r.size() <= 0? null: r.getCellValues(); } @@ -1054,9 +1053,8 @@ public class HTable implements HTableInterface { } } g.setMaxVersions(numVersions); - if (ts != HConstants.LATEST_TIMESTAMP) { - g.setTimeStamp(ts); - } + g.setTimeRange(0, + ts == HConstants.LATEST_TIMESTAMP ? ts : ts+1); Result r = get(g); return r == null || r.size() <= 0? null: r.getRowResult(); } @@ -1310,6 +1308,8 @@ public class HTable implements HTableInterface { scan.addColumn(splits[0], splits[1]); } } + scan.setTimeRange(0, + timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1); OldClientScanner s = new OldClientScanner(new ClientScanner(scan)); s.initialize(); return s; @@ -1706,7 +1706,8 @@ public class HTable implements HTableInterface { final long timestamp, final RowLock rl) throws IOException { final Get g = new Get(row, rl); g.addColumn(column); - g.setTimeStamp(timestamp); + g.setTimeRange(0, + timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1); return exists(g); } diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 72997138f4b..d36546b5633 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1331,10 +1331,9 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ /** - * Checks if any stamps are > now. If so, sets them to now. + * Checks if any stamps is Long.MAX_VALUE. If so, sets them to now. *

- * This acts to be prevent users from inserting future stamps as well as - * to replace LATEST_TIMESTAMP with now. + * This acts to replace LATEST_TIMESTAMP with now. * @param keys * @param now * @return true when updating the time stamp completed. @@ -1344,7 +1343,9 @@ public class HRegion implements HConstants, HeapSize { // , Writable{ return false; } for(KeyValue key : keys) { - key.updateLatestStamp(now); + if(key.getTimestamp() == HConstants.LATEST_TIMESTAMP) { + key.updateLatestStamp(now); + } } return true; }