final _Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { _Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos, hash); }
@Override public void checkpoint() throws IOException { if (!mClosed && mPageDb.isDurable()) { try { checkpoint(false, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } }
@Override public void checkpoint() throws IOException { if (!mClosed && mPageDb.isDurable()) { try { checkpoint(false, 0, 0); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); closeQuietly(null, this, e); throw e; } } }
@Override public void commit(final byte[] tvalue) throws IOException { final byte[] tkey = mKey; ViewUtils.positionCheck(tkey); final Cursor c = mSource; final byte[] key = c.key(); if (key == null) { throw TransformedView.fail(); } c.commit(mTransformer.inverseTransformValue(tvalue, key, tkey)); mValue = tvalue; }
final Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos); }
private void cleanupSplit(Throwable cause, Node newNode, Split split) { if (split != null) { cleanupFragments(cause, split.fragmentedKey()); } try { // No need to prepare for delete because node contents are unreferenced. getDatabase().finishDeleteNode(newNode); } catch (Throwable e) { Utils.suppress(cause, e); panic(cause); } }
@Override public View viewLe(byte[] tkey) { byte[] key = inverseTransformKey(tkey); if (key == null) { key = mTransformer.inverseTransformKeyLt(tkey); if (key == null) { return nonView(); } } return new TransformedView(mSource.viewLe(key), mTransformer); }
private void pushUndoPrepare() throws IOException { final CommitLock.Shared shared = mDatabase.commitLock().acquireShared(); try { undoLog().pushPrepare(); } finally { shared.release(); } }
/** * Reconstruct a fragmented key. */ byte[] reconstructKey(/*P*/ byte[] fragmented, int off, int len) throws IOException { try { return reconstruct(fragmented, off, len); } catch (LargeValueException e) { throw new LargeKeyException(e.getLength(), e.getCause()); } }
final void unlockToShared(_LockOwner locker, _Lock lock) { LockHT ht = getLockHT(lock.mHashCode); ht.acquireExclusive(); try { lock.unlockToShared(locker, ht); } finally { ht.releaseExclusive(); } }
final void unlockToUpgradable(_LockOwner locker, _Lock lock) { LockHT ht = getLockHT(lock.mHashCode); ht.acquireExclusive(); try { lock.unlockToUpgradable(locker, ht); } finally { ht.releaseExclusive(); } }
@Override public LockResult findNearby(byte[] key) throws IOException { if (mView.inRange(key)) { return mSource.findNearby(key); } reset(); return LockResult.UNOWNED; }
@Override public Tree newTemporaryIndex() throws IOException { CommitLock.Shared shared = mCommitLock.acquireShared(); try { return newTemporaryTree(null); } finally { shared.release(); } }
@Override public void scanFreeList(LongConsumer dst) throws IOException { CommitLock.Shared shared = mCommitLock.acquireShared(); try { scanFreeList(I_MANAGER_HEADER + PageManager.I_REGULAR_QUEUE, dst); scanFreeList(I_MANAGER_HEADER + PageManager.I_RECYCLE_QUEUE, dst); } finally { shared.release(); } }
@Override public LockResult open(Transaction txn, byte[] tkey) throws IOException { final byte[] key = mTransformer.inverseTransformKey(tkey); if (key == null) { throw new ViewConstraintException("Unsupported key"); } return mSource.open(txn, key); } }
private void setSplitKey(_Tree tree, _Split split, byte[] fullKey) throws IOException { byte[] actualKey = fullKey; _LocalDatabase db = tree.mDatabase; if (calculateAllowedKeyLength(db, fullKey) < 0) { // Key must be fragmented. actualKey = db.fragmentKey(fullKey); } split.setKey(fullKey, actualKey); }
final _Locker lockExclusiveLocal(long indexId, byte[] key, int hash) throws LockFailureException { _Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_EXCLUSIVE, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_EXCLUSIVE, result, mDefaultTimeoutNanos); }
final Locker lockSharedLocal(long indexId, byte[] key, int hash) throws LockFailureException { Locker locker = localLocker(); LockResult result = getLockHT(hash) .tryLock(TYPE_SHARED, locker, indexId, key, hash, mDefaultTimeoutNanos); if (result.isHeld()) { return locker; } throw locker.failed(TYPE_SHARED, result, mDefaultTimeoutNanos); }