@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 boolean isFull() { if ( BPT.CheckingNode && count > maxRecords() ) BPT.error("isFull: Moby block: %s", this) ; // Count is number of records. return count >= maxRecords() ; }
@Override public String toString() { StringBuilder b = new StringBuilder() ; if ( isLeaf ) b.append("LEAF: ") ; else b.append("NODE: ") ; String labelStr = "??" ; if ( parent >= 0 ) labelStr = Integer.toString(parent) ; else if ( parent == BPlusTreeParams.RootParent ) labelStr = "root" ; if ( isLeaf ) labelStr = labelStr + "/leaf" ; b.append(String.format("%d [%s] (size %d) -- ", getId(), labelStr, count)) ; for ( int i = 0 ; i < maxRecords() ; i++ ) { b.append(childStr(i)) ; b.append(" (") ; b.append(recstr(records, i)) ; b.append(") ") ; } b.append(childStr(params.HighPtr)) ; return b.toString() ; }
@Override public String toString() { StringBuilder b = new StringBuilder() ; if ( isLeaf ) b.append("LEAF: ") ; else b.append("NODE: ") ; String labelStr = "??" ; if ( parent >= 0 ) labelStr = Integer.toString(parent) ; else if ( parent == BPlusTreeParams.RootParent ) labelStr = "root" ; if ( isLeaf ) labelStr = labelStr + "/leaf" ; b.append(String.format("%d [%s] (size %d) -- ", getId(), labelStr, count)) ; for ( int i = 0 ; i < maxRecords() ; i++ ) { b.append(childStr(i)) ; b.append(" (") ; b.append(recstr(records, i)) ; b.append(") ") ; } b.append(childStr(params.HighPtr)) ; return b.toString() ; }
/** Split this block - return the split record (key only needed) */ @Override final BPTreePage split() { // Median record : will go in parent. int ix = params.SplitIndex ; // New block. BPTreeNode z = create(this.parent, isLeaf) ; // Leave the low end untouched and copy, and clear the high end. // z becomes the new upper node, not the lower node. // 'this' is the lower block. int maxRec = maxRecords() ; // Copy from top of y into z. records.copy(ix + 1, z.records, 0, maxRec - (ix + 1)) ; records.clear(ix, maxRec - ix) ; // Clear copied and median slot records.setSize(ix) ; // Reset size ptrs.copy(ix + 1, z.ptrs, 0, params.MaxPtr - (ix + 1)) ; ptrs.clear(ix + 1, params.MaxPtr - (ix + 1)) ; ptrs.setSize(ix + 1) ; // Set sizes of subnodes setCount(ix) ; // Median is ix internalCheckNode() ; // y finished z.isLeaf = isLeaf ; z.setCount(maxRec - (ix + 1)) ; // Number copied into z // Caller puts the blocks in split(int, BTreePage) z.internalCheckNode() ; return z ; }
/** Split this block - return the split record (key only needed) */ @Override final BPTreePage split() { // Median record : will go in parent. int ix = params.SplitIndex ; // New block. BPTreeNode z = create(this.parent, isLeaf) ; // Leave the low end untouched and copy, and clear the high end. // z becomes the new upper node, not the lower node. // 'this' is the lower block. int maxRec = maxRecords() ; // Copy from top of y into z. records.copy(ix + 1, z.records, 0, maxRec - (ix + 1)) ; records.clear(ix, maxRec - ix) ; // Clear copied and median slot records.setSize(ix) ; // Reset size ptrs.copy(ix + 1, z.ptrs, 0, params.MaxPtr - (ix + 1)) ; ptrs.clear(ix + 1, params.MaxPtr - (ix + 1)) ; ptrs.setSize(ix + 1) ; // Set sizes of subnodes setCount(ix) ; // Median is ix internalCheckNode() ; // y finished z.isLeaf = isLeaf ; z.setCount(maxRec - (ix + 1)) ; // Number copied into z // Caller puts the blocks in split(int, BTreePage) z.internalCheckNode() ; return z ; }
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() ; }
if ( !isRoot() && count > maxRecords() ) BPT.error("Over full node: %s", this) ; if ( !isLeaf && parent == id ) for ( int i = count ; i < maxRecords() ; i++ ) { if ( !records.isClear(i) ) BPT.error("Node: %d - not clear (idx=%d) :: %s", id, i, this) ;
if ( !isRoot() && count > maxRecords() ) BPT.error("Over full node: %s", this) ; if ( !isLeaf && parent == id ) for ( int i = count ; i < maxRecords() ; i++ ) { if ( !records.isClear(i) ) BPT.error("Node: %d - not clear (idx=%d) :: %s", id, i, this) ;
root.records.copy(splitIdx + 1, right.records, 0, root.maxRecords() - (splitIdx + 1)) ; root.ptrs.copy(splitIdx + 1, right.ptrs, 0, root.params.MaxPtr - (splitIdx + 1)) ; right.count = root.maxRecords() - (splitIdx + 1) ;
root.records.copy(splitIdx + 1, right.records, 0, root.maxRecords() - (splitIdx + 1)) ; root.ptrs.copy(splitIdx + 1, right.ptrs, 0, root.params.MaxPtr - (splitIdx + 1)) ; right.count = root.maxRecords() - (splitIdx + 1) ;