/** * Returns the highest possible leaf key position, which is an even * number. If leaf node is empty, return value is negative. Caller must * hold any latch. */ int highestLeafPos() { return searchVecEnd() - searchVecStart(); }
/** * Returns the highest possible internal node position, which is an even * number. Highest position doesn't correspond to a valid key, but instead * a child node position. If internal node has no keys, node has one child * at position zero. Caller must hold any latch. */ int highestInternalPos() { return searchVecEnd() - searchVecStart() + 2; }
/** * Caller must hold any latch. * * @see #countNonGhostKeys */ int numKeys() { return (searchVecEnd() - searchVecStart() + 2) >> 1; }
/** * Returns the highest possible internal node position, which is an even * number. Highest position doesn't correspond to a valid key, but instead * a child node position. If internal node has no keys, node has one child * at position zero. Caller must hold any latch. */ int highestInternalPos() { return searchVecEnd() - searchVecStart() + 2; }
/** * Returns the highest possible leaf key position, which is an even * number. If leaf node is empty, return value is negative. Caller must * hold any latch. */ int highestLeafPos() { return searchVecEnd() - searchVecStart(); }
/** * Returns the highest possible key position, which is an even number. If * node has no keys, return value is negative. Caller must hold any latch. */ int highestKeyPos() { return searchVecEnd() - searchVecStart(); }
/** * Applicable only to leaf nodes. Caller must hold any latch. */ int countNonGhostKeys() { return countNonGhostKeys(searchVecStart(), searchVecEnd()); }
/** * @param pos position as provided by binarySearch; must be positive */ byte[] retrieveKey(int pos) throws IOException { final long page = mPage; return retrieveKeyAtLoc(this, page, p_ushortGetLE(page, searchVecStart() + pos)); }
/** * Returns highest leaf or internal position. Caller must hold any latch. */ int highestPos() { int pos = searchVecEnd() - searchVecStart(); if (!isLeaf()) { pos += 2; } return pos; }
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 }
/** * @param pos position as provided by binarySearch; must be positive * @return Cursor.NOT_LOADED if value exists, null if ghost */ byte[] hasLeafValue(int pos) { final long page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); return p_byteGet(page, loc) == -1 ? null : Cursor.NOT_LOADED; }
/** * @param pos position as provided by binarySearch; must be positive */ boolean isFragmentedLeafValue(int pos) { final long page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); int header = p_byteGet(page, loc); return ((header & 0xc0) >= 0xc0) & (header < -1); }
/** * @param pos position as provided by binarySearch; must be positive * @return Cursor.NOT_LOADED if value exists, null if ghost */ byte[] hasLeafValue(int pos) { final long page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); return p_byteGet(page, loc) == -1 ? null : Cursor.NOT_LOADED; }
/** * @param pos position as provided by binarySearch; must be positive */ boolean isFragmentedLeafValue(int pos) { final long page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); int header = p_byteGet(page, loc); return ((header & 0xc0) >= 0xc0) & (header < -1); }
/** * @param pos position as provided by binarySearch; must be positive */ void deleteLeafEntry(int pos) throws IOException { long page = mPage; int entryLoc = p_ushortGetLE(page, searchVecStart() + pos); finishDeleteLeafEntry(pos, doDeleteLeafEntry(page, entryLoc) - entryLoc); }
/** * 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 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)); }