public void checkKeys(Set<Integer> removed) { for (int i = 0; i < numKeys; i++) { if (removed.contains(i)) { assertFalse(store.containsKey(KeyValueStoreUtil.getBuffer(i), tx)); } else { assertTrue(store.containsKey(KeyValueStoreUtil.getBuffer(i), tx)); } } }
@Test public void containsKeyReturnsTrueOnExtantKey() throws Exception { ByteBuffer key1 = KeyColumnValueStoreUtil.longToByteBuffer(1); TransactionHandle txn = manager.beginTransaction(); assertFalse(store.containsKey(key1.duplicate(), txn)); KeyColumnValueStoreUtil.insert(store, txn, 1, "c", "v"); txn.commit(); txn = manager.beginTransaction(); assertTrue(store.containsKey(key1.duplicate(), txn)); txn.commit(); }
@Test public void containsKeyReturnsFalseOnNonexistentKey() throws Exception { TransactionHandle txn = manager.beginTransaction(); ByteBuffer key1 = KeyColumnValueStoreUtil.longToByteBuffer(1); assertFalse(store.containsKey(key1.duplicate(), txn)); txn.commit(); }
@Override public boolean containsVertexID(long id, InternalTitanTransaction tx) { log.trace("Checking node existence for {}", id); for (int readAttempt = 0; readAttempt < maxReadRetryAttempts; readAttempt++) { try { return edgeStore.containsKey(IDHandler.getKey(id), tx.getTxHandle()); } catch (StorageException e) { if (e instanceof TemporaryStorageException) { if (readAttempt < maxReadRetryAttempts - 1) temporaryStorageException(e); else throw readException(e, maxReadRetryAttempts); } else throw readException(e); } } throw new AssertionError("Illegal program state"); }