/** * Test method which confirms that cursor frame nodes are at an extremity. Method is not * tolerant of split nodes. * * @param extremity LOW_EXTREMITY or HIGH_EXTREMITY */ public final boolean verifyExtremities(byte extremity) throws IOException { Node node = latchRootNode(); try { while (true) { if ((node.type() & extremity) == 0) { return false; } if (node.isLeaf()) { return true; } int pos = 0; if (extremity == Node.HIGH_EXTREMITY) { pos = node.highestInternalPos(); } node = latchToChild(node, pos); } } finally { node.releaseShared(); } }
/** * Test method which confirms that cursor frame nodes are at an extremity. Method is not * tolerant of split nodes. * * @param extremity LOW_EXTREMITY or HIGH_EXTREMITY */ public final boolean verifyExtremities(byte extremity) throws IOException { Node node = latchRootNode(); try { while (true) { if ((node.type() & extremity) == 0) { return false; } if (node.isLeaf()) { return true; } int pos = 0; if (extremity == Node.HIGH_EXTREMITY) { pos = node.highestInternalPos(); } node = latchToChild(node, pos); } } finally { node.releaseShared(); } }
/** * Moves the cursor to the first subtree leaf node, which might be empty or full of * ghosts. Leaf frame remains latched when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return latched first node, possibly empty, bound by mLeaf frame */ private Node toFirstLeaf(CursorFrame frame, Node node) throws IOException { try { while (true) { frame.bind(node, 0); if (node.mSplit != null) { node = finishSplitShared(frame, node); if (frame.mNodePos != 0) { // Rebind if position changed (possibly negative). frame.bindOrReposition(node, 0); } } if (node.isLeaf()) { mLeaf = frame; return node; } node = latchToChild(node, 0); frame = new CursorFrame(frame); } } catch (Throwable e) { throw cleanup(e, frame); } }
/** * Moves the cursor to the first subtree leaf node, which might be empty or full of * ghosts. Leaf frame remains latched when method returns normally. * * @param frame frame to bind node to * @param node latched node; can have no keys * @return latched first node, possibly empty, bound by mLeaf frame */ private Node toFirstLeaf(CursorFrame frame, Node node) throws IOException { try { while (true) { frame.bind(node, 0); if (node.mSplit != null) { node = finishSplitShared(frame, node); if (frame.mNodePos != 0) { // Rebind if position changed (possibly negative). frame.bindOrReposition(node, 0); } } if (node.isLeaf()) { mLeaf = frame; return node; } node = latchToChild(node, 0); frame = new CursorFrame(frame); } } catch (Throwable e) { throw cleanup(e, frame); } }
return toLast(new CursorFrame(frame), latchToChild(node, pos)); return toLast(frame, latchToChild(parentNode, parentPos));
return toLast(new CursorFrame(frame), latchToChild(node, pos)); return toLast(frame, latchToChild(parentNode, parentPos));
node = latchToChild(node, childPos);
node = latchToChild(node, childPos);
return toFirstLeaf(new CursorFrame(frame), latchToChild(node, pos)); return toFirstLeaf(frame, latchToChild(parentNode, parentPos));
return toFirstLeaf(new CursorFrame(frame), latchToChild(node, pos)); return toFirstLeaf(frame, latchToChild(parentNode, parentPos));
node = latchToChild(node, childPos); } catch (Throwable e) { throw cleanup(e, frame); node = latchToChild(selected, selectedPos); } catch (Throwable e) { throw cleanup(e, frame);
node = latchToChild(node, childPos); } catch (Throwable e) { throw cleanup(e, frame); node = latchToChild(selected, selectedPos); } catch (Throwable e) { throw cleanup(e, frame);
if (!toLast(new CursorFrame(frame), latchToChild(node, pos))) { return null; childNode = latchToChild(parentNode, parentPos);
if (!toLast(new CursorFrame(frame), latchToChild(node, pos))) { return null; childNode = latchToChild(parentNode, parentPos);
node = latchToChild(node, pos); } catch (Throwable e) { throw cleanup(e, frame);
node = latchToChild(node, pos); } catch (Throwable e) { throw cleanup(e, frame);
if (!toFirst(new CursorFrame(frame), latchToChild(node, pos))) { return null; childNode = latchToChild(parentNode, parentPos);
node = latchToChild(node, pos); } catch (Throwable e) { throw cleanup(e, frame);
node = latchToChild(node, pos); } catch (Throwable e) { throw cleanup(e, frame);
node = latchToChild(node, pos); } catch (Throwable e) { throw cleanup(e, frame);