/** * Applicable only to leaf nodes. Caller must hold any latch. * * @param lowPos 2-based search vector position (inclusive) * @param highPos 2-based search vector position (inclusive) */ int countNonGhostKeys(int lowPos, int highPos) { final /*P*/ byte[] page = mPage; int count = 0; for (int i = lowPos; i <= highPos; i += 2) { int loc = p_ushortGetLE(page, i); if (p_byteGet(page, loc + keyLengthAtLoc(page, loc)) != -1) { count++; } } return count; }
/** * Applicable only to leaf nodes. Caller must hold any latch. * * @param lowPos 2-based search vector position (inclusive) * @param highPos 2-based search vector position (inclusive) */ int countNonGhostKeys(int lowPos, int highPos) { final /*P*/ byte[] page = mPage; int count = 0; for (int i = lowPos; i <= highPos; i += 2) { int loc = p_ushortGetLE(page, i); if (p_byteGet(page, loc + keyLengthAtLoc(page, loc)) != -1) { count++; } } return count; }
/** * Applicable only to leaf nodes, not split. Caller must hold any latch. * * @param lowPos 2-based search vector position (inclusive) * @param highPos 2-based search vector position (inclusive) */ int countNonGhostKeys(int lowPos, int highPos) { final /*P*/ byte[] page = mPage; int count = 0; for (int i = lowPos; i <= highPos; i += 2) { int loc = p_ushortGetLE(page, i); if (p_byteGet(page, loc + keyLengthAtLoc(page, loc)) != -1) { count++; } } return count; }
/** * @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 /*P*/ byte[] 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 /*P*/ byte[] 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 null if ghost */ byte[] retrieveLeafValue(int pos) throws IOException { final /*P*/ byte[] page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); return retrieveLeafValueAtLoc(this, page, loc); }
/** * @param pos position as provided by binarySearch; must be positive */ boolean isFragmentedLeafValue(int pos) { final /*P*/ byte[] 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 /*P*/ byte[] 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 /*P*/ byte[] 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 null if ghost */ byte[] retrieveLeafValue(int pos) throws IOException { final /*P*/ byte[] page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); return retrieveLeafValueAtLoc(this, page, loc); }
/** * @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 /*P*/ byte[] 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 * @return null if ghost */ byte[] retrieveLeafValue(int pos) throws IOException { final /*P*/ byte[] page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc); return retrieveLeafValueAtLoc(this, page, loc); }
/** * @return length of encoded entry at given location */ static int leafEntryLengthAtLoc(/*P*/ byte[] page, final int entryLoc) { int loc = entryLoc + keyLengthAtLoc(page, entryLoc); int header = p_byteGet(page, loc++); if (header >= 0) { loc += header; } else { if ((header & 0x20) == 0) { loc += 2 + (((header & 0x1f) << 8) | p_ubyteGet(page, loc)); } else if (header != -1) { loc += 3 + (((header & 0x0f) << 16) | (p_ubyteGet(page, loc) << 8) | p_ubyteGet(page, loc + 1)); } } return loc - entryLoc; }
/** * @return length of encoded entry at given location */ static int leafEntryLengthAtLoc(/*P*/ byte[] page, final int entryLoc) { int loc = entryLoc + keyLengthAtLoc(page, entryLoc); int header = p_byteGet(page, loc++); if (header >= 0) { loc += header; } else { if ((header & 0x20) == 0) { loc += 2 + (((header & 0x1f) << 8) | p_ubyteGet(page, loc)); } else if (header != -1) { loc += 3 + (((header & 0x0f) << 16) | (p_ubyteGet(page, loc) << 8) | p_ubyteGet(page, loc + 1)); } } return loc - entryLoc; }
/** * @return length of encoded entry at given location */ static int leafEntryLengthAtLoc(/*P*/ byte[] page, final int entryLoc) { int loc = entryLoc + keyLengthAtLoc(page, entryLoc); int header = p_byteGet(page, loc++); if (header >= 0) { loc += header; } else { if ((header & 0x20) == 0) { loc += 2 + (((header & 0x1f) << 8) | p_ubyteGet(page, loc)); } else if (header != -1) { loc += 3 + (((header & 0x0f) << 16) | (p_ubyteGet(page, loc) << 8) | p_ubyteGet(page, loc + 1)); } } return loc - entryLoc; }
/** * Remove an entry from the trash, as an undo operation. Original entry is * stored back into index. * * @param index index to store entry into; pass null to fully delete it instead */ void remove(long txnId, Tree index, byte[] undoEntry) throws IOException { // Extract the index and trash keys. /*P*/ byte[] undo = p_transfer(undoEntry); byte[] indexKey, trashKey; try { DatabaseAccess dbAccess = mTrash.mRoot; indexKey = Node.retrieveKeyAtLoc(dbAccess, undo, 0); int tidLoc = Node.keyLengthAtLoc(undo, 0); int tidLen = undoEntry.length - tidLoc; trashKey = new byte[8 + tidLen]; encodeLongBE(trashKey, 0, txnId); p_copyToArray(undo, tidLoc, trashKey, 8, tidLen); } finally { p_delete(undo); } remove(index, indexKey, trashKey); }
/** * Remove an entry from the trash, as an undo operation. Original entry is * stored back into index. * * @param index index to store entry into; pass null to fully delete it instead */ void remove(long txnId, Tree index, byte[] undoEntry) throws IOException { // Extract the index and trash keys. /*P*/ byte[] undo = p_transfer(undoEntry, false); byte[] indexKey, trashKey; try { DatabaseAccess dbAccess = mTrash.mRoot; indexKey = Node.retrieveKeyAtLoc(dbAccess, undo, 0); int tidLoc = Node.keyLengthAtLoc(undo, 0); int tidLen = undoEntry.length - tidLoc; trashKey = new byte[8 + tidLen]; encodeLongBE(trashKey, 0, txnId); p_copyToArray(undo, tidLoc, trashKey, 8, tidLen); } finally { p_delete(undo); } remove(index, indexKey, trashKey); }
final /*P*/ byte[] page = mPage; int loc = p_ushortGetLE(page, searchVecStart() + pos); loc += keyLengthAtLoc(page, loc);
garbage(garbage() + keyLengthAtLoc(page, entryLoc));
garbage(garbage() + keyLengthAtLoc(page, entryLoc));