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
This commit is contained in:
Jean-Daniel Cryans 2009-08-26 00:03:42 +00:00
parent fcc84c258f
commit de546af646
3 changed files with 15 additions and 11 deletions

View File

@ -6,6 +6,8 @@ Release 0.21.0 - Unreleased
HBASE-1791 Timeout in IndexRecordWriter (Bradford Stephens via Andrew HBASE-1791 Timeout in IndexRecordWriter (Bradford Stephens via Andrew
Purtell) Purtell)
HBASE-1737 Regions unbalanced when adding new node (recommit) 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 IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -796,9 +796,8 @@ public class HTable implements HTableInterface {
g.addColumn(fq[0], fq[1]); g.addColumn(fq[0], fq[1]);
} }
g.setMaxVersions(numVersions); g.setMaxVersions(numVersions);
if (timestamp != HConstants.LATEST_TIMESTAMP) { g.setTimeRange(0,
g.setTimeStamp(timestamp); timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1);
}
Result r = get(g); Result r = get(g);
return r == null || r.size() <= 0? null: r.getCellValues(); return r == null || r.size() <= 0? null: r.getCellValues();
} }
@ -1054,9 +1053,8 @@ public class HTable implements HTableInterface {
} }
} }
g.setMaxVersions(numVersions); g.setMaxVersions(numVersions);
if (ts != HConstants.LATEST_TIMESTAMP) { g.setTimeRange(0,
g.setTimeStamp(ts); ts == HConstants.LATEST_TIMESTAMP ? ts : ts+1);
}
Result r = get(g); Result r = get(g);
return r == null || r.size() <= 0? null: r.getRowResult(); 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.addColumn(splits[0], splits[1]);
} }
} }
scan.setTimeRange(0,
timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1);
OldClientScanner s = new OldClientScanner(new ClientScanner(scan)); OldClientScanner s = new OldClientScanner(new ClientScanner(scan));
s.initialize(); s.initialize();
return s; return s;
@ -1706,7 +1706,8 @@ public class HTable implements HTableInterface {
final long timestamp, final RowLock rl) throws IOException { final long timestamp, final RowLock rl) throws IOException {
final Get g = new Get(row, rl); final Get g = new Get(row, rl);
g.addColumn(column); g.addColumn(column);
g.setTimeStamp(timestamp); g.setTimeRange(0,
timestamp == HConstants.LATEST_TIMESTAMP ? timestamp : timestamp+1);
return exists(g); return exists(g);
} }

View File

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