/** * Opens the index and puts it into the local cache, replacing the existing entry. * * @return null if not found */ private Index openIndex(Transaction txn, long indexId, LHashTable.ObjEntry<SoftReference<Index>> entry) throws IOException { Index ix = mDatabase.anyIndexById(txn, indexId); if (ix == null) { return null; } SoftReference<Index> ref = new SoftReference<>(ix); if (entry == null) { mIndexes.insert(indexId).value = ref; } else { entry.value = ref; } if (entry != null) { // Remove entries for all other cleared references, freeing up memory. mIndexes.traverse((e) -> e.value.get() == null); } return ix; }
/** * Opens the index and puts it into the local cache, replacing the existing entry. * * @return null if not found */ private Index openIndex(Transaction txn, long indexId, LHashTable.ObjEntry<SoftReference<Index>> entry) throws IOException { Index ix = mDatabase.anyIndexById(txn, indexId); if (ix == null) { return null; } SoftReference<Index> ref = new SoftReference<>(ix); if (entry == null) { mIndexes.insert(indexId).value = ref; } else { entry.value = ref; } if (entry != null) { // Remove entries for all other cleared references, freeing up memory. mIndexes.traverse(e -> e.value.get() == null); } return ix; }
/** * Opens the index and puts it into the local cache, replacing the existing entry. * * @param cleanup non-null to remove cleared references * @return null if not found */ private Index openIndex(Transaction txn, long indexId, Object cleanup) throws IOException { Index ix = mDatabase.anyIndexById(txn, indexId); if (ix == null) { return null; } SoftReference<Index> ref = new SoftReference<>(ix); synchronized (mIndexes) { mIndexes.insert(indexId).value = ref; if (cleanup != null) { // Remove entries for all other cleared references, freeing up memory. mIndexes.traverse(e -> e.value.get() == null); } } return ix; }
/** * Opens the index and puts it into the local cache, replacing the existing entry. * * @param cleanup non-null to remove cleared references * @return null if not found */ private Index openIndex(Transaction txn, long indexId, Object cleanup) throws IOException { Index ix = mDatabase.anyIndexById(txn, indexId); if (ix == null) { return null; } SoftReference<Index> ref = new SoftReference<>(ix); synchronized (mIndexes) { mIndexes.insert(indexId).value = ref; if (cleanup != null) { // Remove entries for all other cleared references, freeing up memory. mIndexes.traverse(e -> e.value.get() == null); } } return ix; }
/** * Recover transactions which were recorded by this master log, keyed by * transaction id. Recovered transactions have a NO_REDO durability mode. * All transactions are registered, and so they must be reset after * recovery is complete. Master log is truncated as a side effect of * calling this method. */ void recoverTransactions(LHashTable.Obj<_LocalTransaction> txns, LockMode lockMode, long timeoutNanos) throws IOException { byte[] opRef = new byte[1]; byte[] entry; while ((entry = pop(opRef, true)) != null) { _UndoLog log = recoverUndoLog(opRef[0], entry); _LocalTransaction txn = log.recoverTransaction(lockMode, timeoutNanos); // Reload the _UndoLog, since recoverTransaction consumes it all. txn.recoveredUndoLog(recoverUndoLog(opRef[0], entry)); txns.insert(log.mTxnId).value = txn; } }
/** * Recover transactions which were recorded by this master log, keyed by * transaction id. Recovered transactions have a NO_REDO durability mode. * All transactions are registered, and so they must be reset after * recovery is complete. Master log is truncated as a side effect of * calling this method. */ void recoverTransactions(LHashTable.Obj<LocalTransaction> txns, LockMode lockMode, long timeoutNanos) throws IOException { byte[] opRef = new byte[1]; byte[] entry; while ((entry = pop(opRef, true)) != null) { UndoLog log = recoverUndoLog(opRef[0], entry); LocalTransaction txn = log.recoverTransaction(lockMode, timeoutNanos); // Reload the UndoLog, since recoverTransaction consumes it all. txn.recoveredUndoLog(recoverUndoLog(opRef[0], entry)); txns.insert(log.mTxnId).value = txn; } }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
@Override public boolean cursorRegister(long cursorId, long indexId) throws IOException { Index ix = openIndex(indexId); if (ix != null) { _TreeCursor c = (_TreeCursor) ix.newCursor(Transaction.BOGUS); c.autoload(false); mCursors.insert(cursorId).value = c; } return true; }
@Override public boolean txnEnter(long txnId) throws IOException { LocalTransaction txn = txn(txnId); if (txn == null) { txn = new LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
private Index openIndex(long indexId) throws IOException { LHashTable.ObjEntry<Index> entry = mIndexes.get(indexId); if (entry != null) { return entry.value; } Index ix = mDatabase.anyIndexById(indexId); if (ix != null) { // Maintain a strong reference to the index. mIndexes.insert(indexId).value = ix; } return ix; } }
@Override public boolean txnEnter(long txnId) throws IOException { _LocalTransaction txn = txn(txnId); if (txn == null) { txn = new _LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
@Override public boolean txnEnter(long txnId) throws IOException { LocalTransaction txn = txn(txnId); if (txn == null) { txn = new LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
@Override public boolean cursorRegister(long cursorId, long indexId) throws IOException { Index ix = openIndex(indexId); if (ix != null) { TreeCursor c = (TreeCursor) ix.newCursor(Transaction.BOGUS); c.autoload(false); mCursors.insert(cursorId).value = c; } return true; }
@Override public boolean txnEnter(long txnId) throws IOException { _LocalTransaction txn = txn(txnId); if (txn == null) { txn = new _LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
@Override public boolean txnEnter(long txnId) throws IOException { LocalTransaction txn = txn(txnId); if (txn == null) { txn = new LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
@Override public boolean txnEnter(long txnId) throws IOException { _LocalTransaction txn = txn(txnId); if (txn == null) { txn = new _LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }