final static Record minRecord(BPTreeNode root) { AccessPath path = new AccessPath(root) ; return root.internalMinRecord(path) ; }
final private static void trackPath(AccessPath path, BPTreeNode node, int idx, BPTreePage page) { if ( path != null ) path.add(node, idx, page) ; }
final private static void resetTrackPath(AccessPath path, BPTreeNode node, int idx, BPTreePage page) { if ( path != null ) { path.reset(node, idx, page) ; } }
private BPTreeRecords loadStack(BPTreeNode node) { AccessPath path = new AccessPath(null) ; node.bpTree.startReadBlkMgr(); if ( minRecord == null ) node.internalMinRecord(path) ; else node.internalSearch(path, minRecord) ; List<AccessStep> steps = path.getPath() ; for ( AccessStep step : steps ) { BPTreeNode n = step.node ; Iterator<BPTreePage> it = n.iterator(minRecord, maxRecord) ; if ( it == null || ! it.hasNext() ) continue ; BPTreePage p = it.next() ; stack.push(it) ; } BPTreePage p = steps.get(steps.size()-1).page ; if ( ! ( p instanceof BPTreeRecords ) ) throw new InternalErrorException("Last path step not to a records block") ; node.bpTree.finishReadBlkMgr(); return (BPTreeRecords)p ; }
if ( path.getPath().size() > 2) { List<AccessStep> y = path.getPath().subList(0, path.getPath().size()-2) ; Optional<AccessStep> z = y.stream().filter(e -> e.node.isLeaf() ).findFirst() ; if ( z.isPresent() ) Optional<AccessStep> z2 = path.getPath().stream().filter(e -> e.node.ptrs.get(e.idx) != e.page.getId()).findFirst() ; if ( z2.isPresent() ) error("promote: path error: %s in %s", z2.get(), path) ; List<AccessStep> steps = path.getPath() ;
private BPTreeRecords loadStack(BPTreeNode node) { AccessPath path = new AccessPath(null) ; node.bpTree.startReadBlkMgr(); if ( minRecord == null ) node.internalMinRecord(path) ; else node.internalSearch(path, minRecord) ; List<AccessStep> steps = path.getPath() ; for ( AccessStep step : steps ) { BPTreeNode n = step.node ; Iterator<BPTreePage> it = n.iterator(minRecord, maxRecord) ; if ( it == null || ! it.hasNext() ) continue ; BPTreePage p = it.next() ; stack.push(it) ; } BPTreePage p = steps.get(steps.size()-1).page ; if ( ! ( p instanceof BPTreeRecords ) ) throw new InternalErrorException("Last path step not to a records block") ; node.bpTree.finishReadBlkMgr(); return (BPTreeRecords)p ; }
if ( path.getPath().size() > 2) { List<AccessStep> y = path.getPath().subList(0, path.getPath().size()-2) ; Optional<AccessStep> z = y.stream().filter(e -> e.node.isLeaf() ).findFirst() ; if ( z.isPresent() ) Optional<AccessStep> z2 = path.getPath().stream().filter(e -> e.node.ptrs.get(e.idx) != e.page.getId()).findFirst() ; if ( z2.isPresent() ) error("promote: path error: %s in %s", z2.get(), path) ; List<AccessStep> steps = path.getPath() ;
private BPTreeRecords loadStack(BPTreeNode node) { AccessPath path = new AccessPath(null) ; node.bpTree.startReadBlkMgr(); if ( minRecord == null ) node.internalMinRecord(path) ; else node.internalSearch(path, minRecord) ; List<AccessStep> steps = path.getPath() ; for ( AccessStep step : steps ) { BPTreeNode n = step.node ; Iterator<BPTreePage> it = n.iterator(minRecord, maxRecord) ; if ( it == null || ! it.hasNext() ) continue ; BPTreePage p = it.next() ; stack.push(it) ; } BPTreePage p = steps.get(steps.size()-1).page ; if ( ! ( p instanceof BPTreeRecords ) ) throw new InternalErrorException("Last path step not to a records block") ; node.bpTree.finishReadBlkMgr(); return (BPTreeRecords)p ; }
final static Record maxRecord(BPTreeNode root) { AccessPath path = new AccessPath(root) ; return root.internalMaxRecord(path) ; }
final private static void resetTrackPath(AccessPath path, BPTreeNode node, int idx, BPTreePage page) { if ( path != null ) { path.reset(node, idx, page) ; } }
final private static void trackPath(AccessPath path, BPTreeNode node, int idx, BPTreePage page) { if ( path != null ) path.add(node, idx, page) ; }
private BPTreeRecords loadStack(BPTreeNode node) { AccessPath path = new AccessPath(null) ; node.bpTree.startReadBlkMgr(); if ( minRecord == null ) node.internalMinRecord(path) ; else node.internalSearch(path, minRecord) ; List<AccessStep> steps = path.getPath() ; for ( AccessStep step : steps ) { BPTreeNode n = step.node ; Iterator<BPTreePage> it = n.iterator(minRecord, maxRecord) ; if ( it == null || ! it.hasNext() ) continue ; BPTreePage p = it.next() ; stack.push(it) ; } BPTreePage p = steps.get(steps.size()-1).page ; if ( ! ( p instanceof BPTreeRecords ) ) throw new InternalErrorException("Last path step not to a records block") ; node.bpTree.finishReadBlkMgr(); return (BPTreeRecords)p ; }
final static Record maxRecord(BPTreeNode root) { AccessPath path = new AccessPath(root) ; return root.internalMaxRecord(path) ; }
path.reset(this, idx, page);
final static Record minRecord(BPTreeNode root) { AccessPath path = new AccessPath(root) ; return root.internalMinRecord(path) ; }
path.reset(this, idx, page);
/** Find a record, using the active comparator */ public static Record search(BPTreeNode root, Record rec) { root.internalCheckNodeDeep() ; if ( ! root.isRoot() ) throw new BPTreeException("Search not starting from the root: " + root) ; AccessPath path = new AccessPath(root) ; Record r = root.internalSearch(path, rec) ; return r ; }
/** Find a record, using the active comparator */ public static Record search(BPTreeNode root, Record rec) { root.internalCheckNodeDeep() ; if ( ! root.isRoot() ) throw new BPTreeException("Search not starting from the root: " + root) ; AccessPath path = new AccessPath(root) ; Record r = root.internalSearch(path, rec) ; return r ; }
/** Insert a record - return existing value if any, else null */ public static Record insert(BPTreeNode root, Record record) { if ( logging(log) ) { log(log, "** insert(%s) / root=%d", record, root.getId()) ; if ( DumpTree ) root.dump() ; } if ( !root.isRoot() ) throw new BPTreeException("Insert begins but this is not the root") ; if ( root.isFull() ) { // Root full - root split is a special case. splitRoot(root) ; if ( DumpTree ) root.dump() ; } AccessPath path = new AccessPath(root) ; // Root ready - call insert proper. Record result = root.internalInsert(path, record) ; root.internalCheckNodeDeep() ; if ( logging(log) ) { log(log, "** insert(%s) / finish", record) ; if ( DumpTree ) root.dump() ; } return result ; }
/** Insert a record - return existing value if any, else null */ public static Record insert(BPTreeNode root, Record record) { if ( logging(log) ) { log(log, "** insert(%s) / root=%d", record, root.getId()) ; if ( DumpTree ) root.dump() ; } if ( !root.isRoot() ) throw new BPTreeException("Insert begins but this is not the root") ; if ( root.isFull() ) { // Root full - root split is a special case. splitRoot(root) ; if ( DumpTree ) root.dump() ; } AccessPath path = new AccessPath(root) ; // Root ready - call insert proper. Record result = root.internalInsert(path, record) ; root.internalCheckNodeDeep() ; if ( logging(log) ) { log(log, "** insert(%s) / finish", record) ; if ( DumpTree ) root.dump() ; } return result ; }