/** * Note: When method returns, frame is unlatched and may no longer be * valid. Leaf frame remains latched when method returns true. * * @param frame leaf frame, not split, with shared latch * @return false if nothing left */ private boolean toNext(CursorFrame frame) throws IOException { while (true) { Node node = toNextAny(frame); if (node == null) { return false; } if (node.hasKeys()) { return true; } frame = mLeaf; } }
/** * Note: When method returns, frame is unlatched and may no longer be * valid. Leaf frame remains latched when method returns true. * * @param frame leaf frame, not split, with shared latch * @return false if nothing left */ private boolean toNext(CursorFrame frame) throws IOException { while (true) { Node node = toNextAny(frame); if (node == null) { return false; } if (node.hasKeys()) { return true; } frame = mLeaf; } }
/** * Note: When method returns, frame is unlatched and may no longer be * valid. Leaf frame remains latched when method returns true. * * @param frame leaf frame, not split, with shared latch * @return false if nothing left */ private boolean toNext(CursorFrame frame) throws IOException { while (true) { Node node = toNextLeaf(frame); if (node == null) { return false; } if (node.hasKeys()) { return true; } frame = mFrame; } }
/** * Note: When method returns, frame is unlatched and may no longer be * valid. Leaf frame remains latched when method returns true. * * @param frame leaf frame, not split, with shared latch * @return false if nothing left */ private boolean toPrevious(CursorFrame frame) throws IOException { while (true) { Node node = toPreviousLeaf(frame); if (node == null) { return false; } if (node.hasKeys()) { return true; } frame = mFrame; } }
/** * Moves the cursor to the first subtree entry. Leaf frame remains latched * when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return false if nothing left */ private boolean toFirst(CursorFrame frame, Node node) throws IOException { return toFirstLeaf(frame, node).hasKeys() ? true : toNext(mLeaf); }
boolean shouldMerge(int availBytes) { return mSplit == null && (((type() & (LOW_EXTREMITY | HIGH_EXTREMITY)) == 0 && availBytes >= ((pageSize(mPage) - TN_HEADER_SIZE) >> 1)) || !hasKeys()); }
/** * Moves the cursor to the first subtree entry. Leaf frame remains latched * when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return false if nothing left */ private boolean toFirst(CursorFrame frame, Node node) throws IOException { return toFirstLeaf(frame, node).hasKeys() ? true : toNext(mLeaf); }
/** * Moves the cursor to the first subtree entry. Leaf frame remains latched * when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return false if nothing left */ private boolean toFirst(CursorFrame frame, Node node) throws IOException { return toFirstLeaf(frame, node).hasKeys() ? true : toNext(mFrame); }
/** * Moves the cursor to the last subtree entry. Leaf frame remains latched * when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return false if nothing left */ private boolean toLast(CursorFrame frame, Node node) throws IOException { return toLastLeaf(frame, node).hasKeys() ? true : toPrevious(mFrame); }
boolean shouldMerge(int availBytes) { return mSplit == null && (((type() & (LOW_EXTREMITY | HIGH_EXTREMITY)) == 0 && availBytes >= ((pageSize(mPage) - TN_HEADER_SIZE) >> 1)) || !hasKeys()); }
boolean shouldMerge(int availBytes) { return mSplit == null && (((type() & (LOW_EXTREMITY | HIGH_EXTREMITY)) == 0 && availBytes >= ((pageSize(mPage) - TN_HEADER_SIZE) >> 1)) || !hasKeys()); }
private static boolean isEmpty(Tree tree) { Node root = tree.mRoot; root.acquireShared(); boolean empty = root.isLeaf() && !root.hasKeys(); root.releaseShared(); if (!empty) { // Double check with a cursor. Tree might be composed of many empty leaf nodes. TreeCursor c = tree.newCursor(Transaction.BOGUS); try { c.mKeyOnly = true; c.first(); empty = c.key() == null; } catch (Throwable e) { // Ignore and keep using the tree for now. } finally { c.reset(); } } return empty; } }
if (mustBeEmpty && (!root.isLeaf() || root.hasKeys())) {
if (mustBeEmpty && (!root.isLeaf() || root.hasKeys())) {
if (mustBeEmpty && (!root.isLeaf() || root.hasKeys())) {
try { root.acquireExclusive(); if (!root.hasKeys()) { prepareToDelete(root); root.releaseExclusive();
Node parentNode = parentFrame.acquireExclusive(); if (parentNode.hasKeys()) { parentNode.deleteLeftChildRef(0); } else {