/** * @return -1 if not enough contiguous space surrounding search vector */ private int allocPageEntry(int encodedLen, int leftSpace, int rightSpace) { final int entryLoc; if (encodedLen <= leftSpace && leftSpace >= rightSpace) { // Allocate entry from left segment. entryLoc = leftSegTail(); leftSegTail(entryLoc + encodedLen); } else if (encodedLen <= rightSpace) { // Allocate entry from right segment. entryLoc = rightSegTail() - encodedLen + 1; rightSegTail(entryLoc - 1); } else { // No room. return -1; } return entryLoc; }
/** * @return -1 if not enough contiguous space surrounding search vector */ private int allocPageEntry(int encodedLen, int leftSpace, int rightSpace) { final int entryLoc; if (encodedLen <= leftSpace && leftSpace >= rightSpace) { // Allocate entry from left segment. entryLoc = leftSegTail(); leftSegTail(entryLoc + encodedLen); } else if (encodedLen <= rightSpace) { // Allocate entry from right segment. entryLoc = rightSegTail() - encodedLen + 1; rightSegTail(entryLoc - 1); } else { // No room. return -1; } return entryLoc; }
/** * @return -1 if not enough contiguous space surrounding search vector */ private int allocPageEntry(int encodedLen, int leftSpace, int rightSpace) { final int entryLoc; if (encodedLen <= leftSpace && leftSpace >= rightSpace) { // Allocate entry from left segment. entryLoc = leftSegTail(); leftSegTail(entryLoc + encodedLen); } else if (encodedLen <= rightSpace) { // Allocate entry from right segment. entryLoc = rightSegTail() - encodedLen + 1; rightSegTail(entryLoc - 1); } else { // No room. return -1; } return entryLoc; }
/** * Caller must hold any latch. */ int availableLeafBytes() { return garbage() + searchVecStart() - searchVecEnd() - leftSegTail() + rightSegTail() + (1 - 2); }
/** * Caller must hold any latch. */ int availableLeafBytes() { return garbage() + searchVecStart() - searchVecEnd() - leftSegTail() + rightSegTail() + (1 - 2); }
/** * Caller must hold any latch. */ int availableInternalBytes() { return garbage() + 5 * (searchVecStart() - searchVecEnd()) - leftSegTail() + rightSegTail() + (1 - (5 * 2 + 8)); }
/** * Caller must hold any latch. */ int availableLeafBytes() { return garbage() + searchVecStart() - searchVecEnd() - leftSegTail() + rightSegTail() + (1 - 2); }
/** * Caller must hold any latch. */ int availableInternalBytes() { return garbage() + 5 * (searchVecStart() - searchVecEnd()) - leftSegTail() + rightSegTail() + (1 - (5 * 2 + 8)); }
/** * Caller must hold any latch. */ int availableInternalBytes() { return garbage() + 5 * (searchVecStart() - searchVecEnd()) - leftSegTail() + rightSegTail() + (1 - (5 * 2 + 8)); }
private void clearEntries() { garbage(0); leftSegTail(TN_HEADER_SIZE); int pageSize = pageSize(mPage); rightSegTail(pageSize - 1); // Search vector location must be even. searchVecStart((TN_HEADER_SIZE + ((pageSize - TN_HEADER_SIZE) >> 1)) & ~1); searchVecEnd(searchVecStart() - 2); // inclusive }
private void clearEntries() { garbage(0); leftSegTail(TN_HEADER_SIZE); int pageSize = pageSize(mPage); rightSegTail(pageSize - 1); // Search vector location must be even. searchVecStart((TN_HEADER_SIZE + ((pageSize - TN_HEADER_SIZE) >> 1)) & ~1); searchVecEnd(searchVecStart() - 2); // inclusive }
Node cloneNode() { Node newNode = new Node(mUsageList, mPage); newNode.mId = mId; newNode.mCachedState = mCachedState; /*P*/ // [ newNode.type(type()); newNode.garbage(garbage()); newNode.leftSegTail(leftSegTail()); newNode.rightSegTail(rightSegTail()); newNode.searchVecStart(searchVecStart()); newNode.searchVecEnd(searchVecEnd()); /*P*/ // ] return newNode; }
Node cloneNode() { Node newNode = new Node(mUsageList, mPage); newNode.mId = mId; newNode.mCachedState = mCachedState; /*P*/ // [ newNode.type(type()); newNode.garbage(garbage()); newNode.leftSegTail(leftSegTail()); newNode.rightSegTail(rightSegTail()); newNode.searchVecStart(searchVecStart()); newNode.searchVecEnd(searchVecEnd()); /*P*/ // ] return newNode; }
private void clearEntries() { garbage(0); leftSegTail(TN_HEADER_SIZE); int pageSize = pageSize(mPage); rightSegTail(pageSize - 1); // Search vector location must be even. searchVecStart((TN_HEADER_SIZE + ((pageSize - TN_HEADER_SIZE) >> 1)) & ~1); searchVecEnd(searchVecStart() - 2); // inclusive }
Node cloneNode() { Node newNode = new Node(mContext, mPage); newNode.mId = mId; newNode.mCachedState = mCachedState; /*P*/ // [ newNode.type(type()); newNode.garbage(garbage()); newNode.leftSegTail(leftSegTail()); newNode.rightSegTail(rightSegTail()); newNode.searchVecStart(searchVecStart()); newNode.searchVecEnd(searchVecEnd()); /*P*/ // ] return newNode; }
Node(NodeUsageList usageList) { super(EXCLUSIVE); mUsageList = usageList; mPage = p_stubTreePage(); // Special stub id. Page 0 and 1 are never used by nodes, and negative indicates that // node shouldn't be persisted. mId = -1; mCachedState = CACHED_CLEAN; /*P*/ // [ type(TYPE_TN_IN); garbage(0); leftSegTail(TN_HEADER_SIZE); rightSegTail(TN_HEADER_SIZE + 8 - 1); searchVecStart(TN_HEADER_SIZE); searchVecEnd(TN_HEADER_SIZE - 2); // inclusive /*P*/ // ] }
Node(NodeUsageList usageList) { super(EXCLUSIVE); mUsageList = usageList; mPage = p_stubTreePage(); // Special stub id. Page 0 and 1 are never used by nodes, and negative indicates that // node shouldn't be persisted. mId = -1; mCachedState = CACHED_CLEAN; /*P*/ // [ type(TYPE_TN_IN); garbage(0); leftSegTail(TN_HEADER_SIZE); rightSegTail(TN_HEADER_SIZE + 8 - 1); searchVecStart(TN_HEADER_SIZE); searchVecEnd(TN_HEADER_SIZE - 2); // inclusive /*P*/ // ] }
/** * Prepares the node for appending entries out-of-order, and then sorting them. * * @see appendToSortLeaf */ void asSortLeaf() { type((byte) (TYPE_TN_LEAF | LOW_EXTREMITY | HIGH_EXTREMITY)); garbage(0); leftSegTail(TN_HEADER_SIZE); int pageSize = pageSize(mPage); rightSegTail(pageSize - 1); // Position search vector on the left side, but appendToSortLeaf will move it to the // right. It's not safe to position an empty search vector on the right side, because // the inclusive start position would wrap around for the largest page size. searchVecStart(TN_HEADER_SIZE); searchVecEnd(TN_HEADER_SIZE - 2); // inclusive }
Node(NodeContext context) { super(EXCLUSIVE); mContext = context; mPage = p_stubTreePage(); // Special stub id. Page 0 and 1 are never used by nodes, and negative indicates that // node shouldn't be persisted. mId = -1; mCachedState = CACHED_CLEAN; /*P*/ // [ type(TYPE_TN_IN); garbage(0); leftSegTail(TN_HEADER_SIZE); rightSegTail(TN_HEADER_SIZE + 8 - 1); searchVecStart(TN_HEADER_SIZE); searchVecEnd(TN_HEADER_SIZE - 2); // inclusive /*P*/ // ] }
private /*P*/ byte[] prepareWrite() { if (mSplit != null) { throw new AssertionError("Cannot write partially split node"); } /*P*/ byte[] page = mPage; /*P*/ // [ if (type() != TYPE_FRAGMENT) { p_bytePut(page, 0, type()); p_bytePut(page, 1, 0); // reserved // For undo log node, this is top entry pointer. p_shortPutLE(page, 2, garbage()); if (type() != TYPE_UNDO_LOG) { p_shortPutLE(page, 4, leftSegTail()); p_shortPutLE(page, 6, rightSegTail()); p_shortPutLE(page, 8, searchVecStart()); p_shortPutLE(page, 10, searchVecEnd()); } } /*P*/ // ] return page; }