HBASE-1954 Transactional scans do not see newest put

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@832526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-11-03 19:40:08 +00:00
parent 8cffa38ba3
commit 4531ccda91
2 changed files with 32 additions and 0 deletions

View File

@ -138,6 +138,14 @@ class TransactionState {
} }
void addWrite(final Put write) { void addWrite(final Put write) {
byte [] now = Bytes.toBytes(System.currentTimeMillis());
// HAVE to manually set the KV timestamps
for (List<KeyValue> kvs : write.getFamilyMap().values()) {
for (KeyValue kv : kvs) {
kv.updateLatestStamp(now);
}
}
puts.add(write); puts.add(write);
} }

View File

@ -170,6 +170,30 @@ public class TestTransactions extends HBaseClusterTestCase {
Assert.assertEquals(row2Value, Bytes.toInt(result.value())); Assert.assertEquals(row2Value, Bytes.toInt(result.value()));
} }
public void testPutPutScan() throws IOException {
TransactionState transactionState = transactionManager.beginTransaction();
int row2Value = 199;
table.put(transactionState, new Put(ROW2).add(FAMILY, QUAL_A, Bytes
.toBytes(row2Value)));
row2Value = 299;
table.put(transactionState, new Put(ROW2).add(FAMILY, QUAL_A, Bytes
.toBytes(row2Value)));
ResultScanner scanner = table.getScanner(transactionState, new Scan()
.addFamily(FAMILY));
Result result = scanner.next();
Assert.assertNotNull(result);
Assert.assertEquals(Bytes.toString(ROW1), Bytes.toString(result.getRow()));
result = scanner.next();
Assert.assertNotNull(result);
Assert.assertEquals(Bytes.toString(ROW2), Bytes.toString(result.getRow()));
Assert.assertEquals(row2Value, Bytes.toInt(result.value()));
}
// Read from ROW1,COL_A and put it in ROW2_COLA and ROW3_COLA // Read from ROW1,COL_A and put it in ROW2_COLA and ROW3_COLA
private TransactionState makeTransaction1() throws IOException { private TransactionState makeTransaction1() throws IOException {
TransactionState transactionState = transactionManager.beginTransaction(); TransactionState transactionState = transactionManager.beginTransaction();