@Override Record shiftLeft(BPTreePage other, Record splitKey) { BPTreeNode node = cast(other) ; if ( BPT.CheckingNode ) { if ( count == 0 ) BPT.error("Node is empty - can't shift a slot out") ; if ( isFull() ) BPT.error("Destination node is full") ; } Record r = node.records.getLow() ; // Records: promote moving element, replace with splitKey this.records.add(splitKey) ; node.records.shiftDown(0) ; // Pointers just shift this.ptrs.shiftLeft(node.ptrs) ; this.count++ ; node.count-- ; return r ; }
@Override Record shiftLeft(BPTreePage other, Record splitKey) { BPTreeNode node = cast(other) ; if ( BPT.CheckingNode ) { if ( count == 0 ) BPT.error("Node is empty - can't shift a slot out") ; if ( isFull() ) BPT.error("Destination node is full") ; } Record r = node.records.getLow() ; // Records: promote moving element, replace with splitKey this.records.add(splitKey) ; node.records.shiftDown(0) ; // Pointers just shift this.ptrs.shiftLeft(node.ptrs) ; this.count++ ; node.count-- ; return r ; }
@Override Record shiftRight(BPTreePage other, Record splitKey) { BPTreeNode node = cast(other) ; if ( BPT.CheckingNode ) { if ( count == 0 ) BPT.error("Node is empty - can't shift a slot out") ; if ( node.isFull() ) BPT.error("Destination node is full") ; } // Records: promote moving element, replace with splitKey Record r = this.records.getHigh() ; this.records.removeTop() ; node.records.add(0, splitKey) ; // Pointers just shift this.ptrs.shiftRight(node.ptrs) ; this.count-- ; node.count++ ; this.internalCheckNode() ; node.internalCheckNode() ; return r ; }
@Override Record shiftRight(BPTreePage other, Record splitKey) { BPTreeNode node = cast(other) ; if ( BPT.CheckingNode ) { if ( count == 0 ) BPT.error("Node is empty - can't shift a slot out") ; if ( node.isFull() ) BPT.error("Destination node is full") ; } // Records: promote moving element, replace with splitKey Record r = this.records.getHigh() ; this.records.removeTop() ; node.records.add(0, splitKey) ; // Pointers just shift this.ptrs.shiftRight(node.ptrs) ; this.count-- ; node.count++ ; this.internalCheckNode() ; node.internalCheckNode() ; 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 ; }