use of org.h2.mvstore.db.TransactionStore.TransactionMap in project h2database by h2database.
the class TestTransactionStore method testGetModifiedMaps.
private void testGetModifiedMaps() {
MVStore s = MVStore.open(null);
TransactionStore ts = new TransactionStore(s);
ts.init();
Transaction tx;
TransactionMap<String, String> m1, m2, m3;
long sp;
tx = ts.begin();
m1 = tx.openMap("m1");
m2 = tx.openMap("m2");
m3 = tx.openMap("m3");
assertFalse(tx.getChanges(0).hasNext());
tx.commit();
tx = ts.begin();
m1 = tx.openMap("m1");
m2 = tx.openMap("m2");
m3 = tx.openMap("m3");
m1.put("1", "100");
sp = tx.setSavepoint();
m2.put("1", "100");
m3.put("1", "100");
Iterator<Change> it = tx.getChanges(sp);
assertTrue(it.hasNext());
Change c;
c = it.next();
assertEquals("m3", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertTrue(it.hasNext());
c = it.next();
assertEquals("m2", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertFalse(it.hasNext());
it = tx.getChanges(0);
assertTrue(it.hasNext());
c = it.next();
assertEquals("m3", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertTrue(it.hasNext());
c = it.next();
assertEquals("m2", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertTrue(it.hasNext());
c = it.next();
assertEquals("m1", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertFalse(it.hasNext());
tx.rollbackToSavepoint(sp);
it = tx.getChanges(0);
assertTrue(it.hasNext());
c = it.next();
assertEquals("m1", c.mapName);
assertEquals("1", c.key.toString());
assertNull(c.value);
assertFalse(it.hasNext());
tx.commit();
s.close();
}
Aggregations