Esempio n. 1
0
  @Test
  public void delayedUpdate() throws Exception {
    View ix = openIndex("foo");

    byte[] key = "hello".getBytes();
    byte[] value1 = "world".getBytes();

    ix.store(null, key, value1);

    int i = 0;
    Updater u = start(ix, key, ("world-" + (i++)).getBytes());

    fastAssertArrayEquals(u.mValue, ix.load(null, key));

    u = start(ix, key, ("world-" + (i++)).getBytes());
    Transaction txn2 = mDb.newTransaction();
    fastAssertArrayEquals(u.mValue, ix.load(txn2, key));
    txn2.reset();

    u = start(ix, key, ("world-" + (i++)).getBytes());
    txn2.lockMode(LockMode.UPGRADABLE_READ);
    fastAssertArrayEquals(u.mValue, ix.load(txn2, key));
    txn2.reset();

    u = start(ix, key, ("world-" + (i++)).getBytes());
    txn2.lockMode(LockMode.REPEATABLE_READ);
    fastAssertArrayEquals(u.mValue, ix.load(txn2, key));
    txn2.reset();

    u = start(ix, key, ("world-" + (i++)).getBytes());
    txn2.lockMode(LockMode.READ_COMMITTED);
    fastAssertArrayEquals(u.mValue, ix.load(txn2, key));
    txn2.reset();
  }
Esempio n. 2
0
  private void delayedDelete(boolean noGhost) throws Exception {
    View ix = openIndex("foo");

    byte[] key = "hello".getBytes();
    byte[] value1 = "world".getBytes();

    ix.store(null, key, value1);

    Updater u = start(ix, key, null, noGhost);

    assertEquals(null, ix.load(null, key));

    ix.store(null, key, value1);
    u = start(ix, key, null, noGhost);
    Transaction txn2 = mDb.newTransaction();
    assertEquals(null, ix.load(txn2, key));
    txn2.reset();

    ix.store(null, key, value1);
    u = start(ix, key, null, noGhost);
    txn2.lockMode(LockMode.UPGRADABLE_READ);
    assertEquals(null, ix.load(txn2, key));
    txn2.reset();

    ix.store(null, key, value1);
    u = start(ix, key, null, noGhost);
    txn2.lockMode(LockMode.REPEATABLE_READ);
    assertEquals(null, ix.load(txn2, key));
    txn2.reset();

    ix.store(null, key, value1);
    u = start(ix, key, null, noGhost);
    txn2.lockMode(LockMode.READ_COMMITTED);
    assertEquals(null, ix.load(txn2, key));
    txn2.reset();
  }