/** * 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; }
/** * 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; }
trees = new ArrayList<>(mOpenTreesById.size()); mOpenTreesById.traverse((entry) -> { trees.add(entry.value); return true;
trees = new ArrayList<>(mOpenTreesById.size()); mOpenTreesById.traverse((entry) -> { trees.add(entry.value); return true;
txnTable = new TxnTable(txns.size()); txns.traverse((entry) -> {
remaining.traverse(entry -> { mTransactions.insert(entry.key).mTxn = entry.value; return false;
remaining.traverse(entry -> { mTransactions.insert(entry.key).mTxn = entry.value; return false;
txnTable = new TxnTable(txns.size()); txns.traverse(te -> { long scrambledTxnId = mix(te.key); LocalTransaction txn = te.value;
txnTable = new TxnTable(txns.size()); txns.traverse((entry) -> {
txnTable = new TxnTable(txns.size()); txns.traverse(te -> { long scrambledTxnId = mix(te.key); _LocalTransaction txn = te.value;
/** * To be called only when shouldInvokeRecoveryHandler returns true. * * @param redo non-null _RedoWriter assigned to each transaction */ void invokeRecoveryHandler(LHashTable.Obj<_LocalTransaction> txns, _RedoWriter redo) { RecoveryHandler handler = mRecoveryHandler; txns.traverse(entry -> { _LocalTransaction txn = entry.value; txn.recoverPrepared (redo, mDurabilityMode, LockMode.UPGRADABLE_READ, mDefaultLockTimeoutNanos); try { handler.recover(txn); } catch (Throwable e) { if (!isClosed()) { EventListener listener = mEventListener; if (listener == null) { uncaught(e); } else { listener.notify(EventType.RECOVERY_HANDLER_UNCAUGHT, "Uncaught exception from recovery handler: %1$s", e); } } } return true; }); }
/** * To be called only when shouldInvokeRecoveryHandler returns true. * * @param redo non-null RedoWriter assigned to each transaction */ void invokeRecoveryHandler(LHashTable.Obj<LocalTransaction> txns, RedoWriter redo) { RecoveryHandler handler = mRecoveryHandler; txns.traverse(entry -> { LocalTransaction txn = entry.value; txn.recoverPrepared (redo, mDurabilityMode, LockMode.UPGRADABLE_READ, mDefaultLockTimeoutNanos); try { handler.recover(txn); } catch (Throwable e) { if (!isClosed()) { EventListener listener = mEventListener; if (listener == null) { uncaught(e); } else { listener.notify(EventType.RECOVERY_HANDLER_UNCAUGHT, "Uncaught exception from recovery handler: %1$s", e); } } } return true; }); }
/** * 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. * * @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; }
void resetCursors() { mCursors.traverse(entry -> { _TreeCursor cursor = entry.value; // Unregister first, to prevent close from writing a redo log entry. mDatabase.unregisterCursor(cursor); cursor.close(); return false; }); }
void resetCursors() { mCursors.traverse(entry -> { TreeCursor cursor = entry.value; // Unregister first, to prevent close from writing a redo log entry. mDatabase.unregisterCursor(cursor); cursor.close(); return false; }); }