private static final BPTreeNode cast(BPTreePage other) { try { return (BPTreeNode)other ; } catch (ClassCastException ex) { BPT.error("Wrong type: " + other) ; return null ; } }
private static final BPTreeNode cast(BPTreePage other) { try { return (BPTreeNode)other ; } catch (ClassCastException ex) { BPT.error("Wrong type: " + other) ; return null ; } }
@Override final boolean isMinSize() { int min = params.getMinRec() ; if ( BPT.CheckingNode && count < min ) BPT.error("isMinSize: Dwarf block: %s", this) ; return count <= min ; }
@Override final boolean isMinSize() { int min = params.getMinRec() ; if ( BPT.CheckingNode && count < min ) BPT.error("isMinSize: Dwarf block: %s", this) ; return count <= min ; }
@Override final void checkNodeDeep() { if ( isRoot() ) { // if ( !isLeaf && count == 0 ) // error("Root is of size zero (one pointer) but not a leaf") ; if ( parent != BPlusTreeParams.RootParent ) BPT.error("Root parent is wrong") ; // if ( count == 0 ) // return ; } checkNodeDeep(null, null) ; }
@Override final boolean isFull() { if ( BPT.CheckingNode && count > maxRecords() ) BPT.error("isFull: Moby block: %s", this) ; // Count is number of records. return count >= maxRecords() ; }
@Override final void checkNodeDeep() { if ( isRoot() ) { // if ( !isLeaf && count == 0 ) // error("Root is of size zero (one pointer) but not a leaf") ; if ( parent != BPlusTreeParams.RootParent ) BPT.error("Root parent is wrong") ; // if ( count == 0 ) // return ; } checkNodeDeep(null, null) ; }
@Override final boolean isFull() { if ( BPT.CheckingNode && count > maxRecords() ) BPT.error("isFull: Moby block: %s", this) ; // Count is number of records. return count >= maxRecords() ; }
@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 ; }
private void shuffleDown(int x) { // x is the index in the parent and may be on eover the end. if ( logging(log) ) { log(log, "ShuffleDown: i=%d count=%d MaxRec=%d", x, count, maxRecords()) ; log(log, "ShuffleDown >> %s", this) ; } if ( BPT.CheckingNode && x >= count ) BPT.error("shuffleDown out of bounds") ; // Just the top to clear if ( x == count - 1 ) { records.removeTop() ; ptrs.removeTop() ; count-- ; if ( logging(log) ) { log(log, "shuffleDown << Clear top") ; log(log, "shuffleDown << %s", this) ; } internalCheckNode() ; return ; } // Shuffle down. Removes key and pointer just above key. records.shiftDown(x) ; ptrs.shiftDown(x + 1) ; count-- ; if ( logging(log) ) log(log, "shuffleDown << %s", this) ; internalCheckNode() ; }
private void shuffleDown(int x) { // x is the index in the parent and may be on eover the end. if ( logging(log) ) { log(log, "ShuffleDown: i=%d count=%d MaxRec=%d", x, count, maxRecords()) ; log(log, "ShuffleDown >> %s", this) ; } if ( BPT.CheckingNode && x >= count ) BPT.error("shuffleDown out of bounds") ; // Just the top to clear if ( x == count - 1 ) { records.removeTop() ; ptrs.removeTop() ; count-- ; if ( logging(log) ) { log(log, "shuffleDown << Clear top") ; log(log, "shuffleDown << %s", this) ; } internalCheckNode() ; return ; } // Shuffle down. Removes key and pointer just above key. records.shiftDown(x) ; ptrs.shiftDown(x + 1) ; count-- ; if ( logging(log) ) log(log, "shuffleDown << %s", this) ; internalCheckNode() ; }
BPT.error("Not an empty root") ;
BPT.error("Not an empty root") ;
BPT.error("Zero size leaf root but not pointing to a records block") ; trackPath(path, root, 0, page) ; Record r = page.internalDelete(path, rec) ;
BPT.error("Zero size leaf root but not pointing to a records block") ; trackPath(path, root, 0, page) ; Record r = page.internalDelete(path, rec) ;