static int p_uintVarSize(int v) { return calcUnsignedVarIntLength(v); }
static int p_ulongVarSize(long v) { return Utils.calcUnsignedVarLongLength(v); }
@Override public final byte[] getName() { return cloneArray(mName); }
encodeShortLE(newValue, 1, (int) vlength); // full length encodeShortLE(newValue, 1 + 2, (int) vlength); // inline length arrayCopyOrFill(value, 0, newValue, (1 + 2 + 2), (int) vlength); return newValue; } else { _Node node = allocDirtyFragmentNode(); try { encodeInt48LE(newValue, poffset, node.mId); p_copyFromArray(value, voffset, node.mPage, 0, pageSize); if (pageCount == 1) { deleteFragment(decodeUnsignedInt48LE(newValue, poffset)); encodeShortLE(newValue, offset, remainder); // inline length arrayCopyOrFill(value, 0, newValue, offset + 2, remainder); _Node node = allocDirtyFragmentNode(); try { encodeInt48LE(newValue, poffset, node.mId); long page = node.mPage; if (pageCount > 1) { deleteFragment(decodeUnsignedInt48LE(newValue, poffset)); encodeInt48LE(newValue, offset, 0); } else { int levels = calculateInodeLevels(vlength); _Node inode = allocDirtyFragmentNode();
long delta = convertSignedVarLong(mRedoFirstTxnId - redoWriterLastTxnId); int varLen = calcUnsignedVarLongLength(delta); offset = (1 + 9) - varLen; encodeUnsignedVarLong(buffer, offset, delta); buffer[--offset] = buffer[0]; length -= offset; mRedoWriterPos = redo.write(commit, buffer, offset, length); } catch (IOException e) { throw rethrow(e, redo.mCloseCause);
@Override public String toString() { StringBuilder b = new StringBuilder(Transaction.class.getName()); if (this == BOGUS) { return b.append('.').append("BOGUS").toString(); } b.append('@').append(Integer.toHexString(hashCode())); b.append(" {"); b.append("id").append(": ").append(mTxnId); b.append(", "); b.append("durabilityMode").append(": ").append(mDurabilityMode); b.append(", "); b.append("lockMode").append(": ").append(mLockMode); b.append(", "); b.append("lockTimeout").append(": "); TimeUnit unit = Utils.inferUnit(TimeUnit.NANOSECONDS, mLockTimeoutNanos); Utils.appendTimeout(b, lockTimeout(unit), unit); Object att = mAttachment; if (att != null) { b.append(", "); b.append("attachment").append(": ").append(att); } Object borked = mBorked; if (borked != null) { b.append(", "); b.append("invalid").append(": ").append(borked); } return b.append('}').toString(); }
/** * Caller must hold db commit lock. */ void pushUnwrite(long indexId, byte[] key, long pos, byte[] b, int off, int len) throws IOException { setActiveIndexIdAndKey(indexId, key); int pLen = calcUnsignedVarLongLength(pos); int varIntLen = calcUnsignedVarIntLength(pLen + len); doPush(OP_UNWRITE, b, off, len, varIntLen, pLen); // Now encode the pos in the reserved region before the payload. _Node node = mNode; int posOff = 1 + varIntLen; if (node != null) { p_ulongPutVar(node.mPage, mNodeTopPos + posOff, pos); } else { encodeUnsignedVarLong(mBuffer, mBufferPos + posOff, pos); } }
@Override void checkpointAborted() { if (mNextOut != null) { Utils.closeQuietly(null, mNextOut); mNextOut = null; } }
private IOException closeOnFailure(Throwable e) throws IOException { throw Utils.closeOnFailure(this, e); }
@Override public int compare(byte[] a, byte[] b) { return Utils.compareUnsigned(a, 0, a.length, b, 0, b.length); } }
static String timeoutMessage(long nanosTimeout, DatabaseException ex) { String msg; if (nanosTimeout == 0) { msg = "Never waited"; } else if (nanosTimeout < 0) { msg = "Infinite wait"; } else { StringBuilder b = new StringBuilder("Waited "); appendTimeout(b, ex.getTimeout(), ex.getUnit()); Object att = ex.getOwnerAttachment(); if (att != null) { appendAttachment(b, att); } return b.toString(); } Object att = ex.getOwnerAttachment(); if (att != null) { StringBuilder b = new StringBuilder(msg); appendAttachment(b, att); msg = b.toString(); } return msg; }
static void initCause(Throwable e, Throwable cause) { if (e != null && cause != null && !cycleCheck(e, cause) && !cycleCheck(cause, e)) { try { e.initCause(cause); } catch (Throwable e2) { } } }
encodeShortLE(newValue, 1, (int) vlength); // full length encodeShortLE(newValue, 1 + 2, (int) vlength); // inline length arrayCopyOrFill(value, 0, newValue, (1 + 2 + 2), (int) vlength); return newValue; } else { Node node = allocDirtyFragmentNode(); try { encodeInt48LE(newValue, poffset, node.mId); p_copyFromArray(value, voffset, node.mPage, 0, pageSize); if (pageCount == 1) { deleteFragment(decodeUnsignedInt48LE(newValue, poffset)); encodeShortLE(newValue, offset, remainder); // inline length arrayCopyOrFill(value, 0, newValue, offset + 2, remainder); Node node = allocDirtyFragmentNode(); try { encodeInt48LE(newValue, poffset, node.mId); /*P*/ byte[] page = node.mPage; if (pageCount > 1) { deleteFragment(decodeUnsignedInt48LE(newValue, poffset)); encodeInt48LE(newValue, offset, 0); } else { int levels = calculateInodeLevels(vlength); Node inode = allocDirtyFragmentNode();
long delta = convertSignedVarLong(mRedoFirstTxnId - redoWriterLastTxnId); int varLen = calcUnsignedVarLongLength(delta); offset = (1 + 9) - varLen; encodeUnsignedVarLong(buffer, offset, delta); buffer[--offset] = buffer[0]; length -= offset; mRedoWriterPos = redo.write(commit, buffer, offset, length); } catch (IOException e) { throw rethrow(e, redo.mCloseCause);
@Override public String toString() { StringBuilder b = new StringBuilder(Transaction.class.getName()); if (this == BOGUS) { return b.append('.').append("BOGUS").toString(); } b.append('@').append(Integer.toHexString(hashCode())); b.append(" {"); b.append("id").append(": ").append(mTxnId); b.append(", "); b.append("durabilityMode").append(": ").append(mDurabilityMode); b.append(", "); b.append("lockMode").append(": ").append(mLockMode); b.append(", "); b.append("lockTimeout").append(": "); TimeUnit unit = Utils.inferUnit(TimeUnit.NANOSECONDS, mLockTimeoutNanos); Utils.appendTimeout(b, lockTimeout(unit), unit); Object att = mAttachment; if (att != null) { b.append(", "); b.append("attachment").append(": ").append(att); } Object borked = mBorked; if (borked != null) { b.append(", "); b.append("invalid").append(": ").append(borked); } return b.append('}').toString(); }
/** * Caller must hold db commit lock. */ void pushUnwrite(long indexId, byte[] key, long pos, byte[] b, int off, int len) throws IOException { setActiveIndexIdAndKey(indexId, key); int pLen = calcUnsignedVarLongLength(pos); int varIntLen = calcUnsignedVarIntLength(pLen + len); doPush(OP_UNWRITE, b, off, len, varIntLen, pLen); // Now encode the pos in the reserved region before the payload. Node node = mNode; int posOff = 1 + varIntLen; if (node != null) { p_ulongPutVar(node.mPage, mNodeTopPos + posOff, pos); } else { encodeUnsignedVarLong(mBuffer, mBufferPos + posOff, pos); } }
@Override void checkpointAborted() { if (mNextOut != null) { Utils.closeQuietly(mNextOut); mNextOut = null; } }
private IOException closeOnFailure(Throwable e) throws IOException { throw Utils.closeOnFailure(this, e); }
/** * @param end must not be null * @param key must not be null * @return <0 if less than end (in range), 0 if equal (in range), >0 if higher */ int endRangeCompare(byte[] end, byte[] key) { int result = compareUnsigned(key, 0, key.length, end, 0, end.length); return result != 0 ? result : (mMode & END_EXCLUSIVE); }
static String timeoutMessage(long nanosTimeout, DatabaseException ex) { String msg; if (nanosTimeout == 0) { msg = "Never waited"; } else if (nanosTimeout < 0) { msg = "Infinite wait"; } else { StringBuilder b = new StringBuilder("Waited "); appendTimeout(b, ex.getTimeout(), ex.getUnit()); Object att = ex.getOwnerAttachment(); if (att != null) { appendAttachment(b, att); } return b.toString(); } Object att = ex.getOwnerAttachment(); if (att != null) { StringBuilder b = new StringBuilder(msg); appendAttachment(b, att); msg = b.toString(); } return msg; }