static void log(Logger log, String fmt, Object... args) { if ( logging(log) ) { FmtLog.debug(log, fmt, args); } }
static void log(Logger log, String fmt, Object... args) { if ( logging(log) ) { FmtLog.debug(log, fmt, args); } }
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() ; }
private void shiftLeft(BPTreePage left, BPTreePage right, int i) { if ( logging(log) ) { log(log, ">> shiftLeft: this: %s", this) ; log(log, ">> shiftLeft: left: %s", left) ; log(log, ">> shiftLeft: right: %s", right) ; } Record r1 = records.get(i) ; Record r2 = left.shiftLeft(right, r1) ; r2 = keyRecord(r2) ; this.records.set(i, r2) ; left.write() ; right.write() ; // Do this later - this.put(); if ( logging(log) ) { log(log, "<< shiftLeft: this: %s", this) ; log(log, "<< shiftLeft: left: %s", left) ; log(log, "<< shiftLeft: right: %s", right) ; } }
private void shiftRight(BPTreePage left, BPTreePage right, int i) { if ( logging(log) ) { log(log, ">> shiftRight: this: %s", this) ; log(log, ">> shiftRight: left: %s", left) ; log(log, ">> shiftRight: right: %s", right) ; } Record r1 = records.get(i) ; Record r2 = left.shiftRight(right, r1) ; r2 = keyRecord(r2) ; this.records.set(i, r2) ; left.write() ; right.write() ; // Do later -- this.put(); if ( logging(log) ) { log(log, "<< shiftRight: this: %s", this) ; log(log, "<< shiftRight: left: %s", left) ; log(log, "<< shiftRight: right: %s", right) ; } }
private void shiftLeft(BPTreePage left, BPTreePage right, int i) { if ( logging(log) ) { log(log, ">> shiftLeft: this: %s", this) ; log(log, ">> shiftLeft: left: %s", left) ; log(log, ">> shiftLeft: right: %s", right) ; } Record r1 = records.get(i) ; Record r2 = left.shiftLeft(right, r1) ; r2 = keyRecord(r2) ; this.records.set(i, r2) ; left.write() ; right.write() ; // Do this later - this.put(); if ( logging(log) ) { log(log, "<< shiftLeft: this: %s", this) ; log(log, "<< shiftLeft: left: %s", left) ; log(log, "<< shiftLeft: right: %s", right) ; } }
private void shiftRight(BPTreePage left, BPTreePage right, int i) { if ( logging(log) ) { log(log, ">> shiftRight: this: %s", this) ; log(log, ">> shiftRight: left: %s", left) ; log(log, ">> shiftRight: right: %s", right) ; } Record r1 = records.get(i) ; Record r2 = left.shiftRight(right, r1) ; r2 = keyRecord(r2) ; this.records.set(i, r2) ; left.write() ; right.write() ; // Do later -- this.put(); if ( logging(log) ) { log(log, "<< shiftRight: this: %s", this) ; log(log, "<< shiftRight: left: %s", left) ; log(log, "<< shiftRight: right: %s", right) ; } }
/** 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 ; }
@Override final Record internalInsert(AccessPath path, Record record) { if ( logging(log) ) log(log, "internalInsert: %s [%s]", record, this) ; if ( logging(log) ) log(log, "internalInsert: idx=%d (=>%d)", idx, apply(idx)) ; trackPath(path, this, idx, page) ; if ( logging(log) ) log(log, "internalInsert: next: %s", page) ;
@Override final Record internalInsert(AccessPath path, Record record) { if ( logging(log) ) log(log, "internalInsert: %s [%s]", record, this) ; if ( logging(log) ) log(log, "internalInsert: idx=%d (=>%d)", idx, apply(idx)) ; trackPath(path, this, idx, page) ; if ( logging(log) ) log(log, "internalInsert: next: %s", page) ;
if ( logging(log) ) { log(log, ">> merge(@%d): %s", dividingSlot, this) ; log(log, ">> left: %s", left) ; BPTreePage page = left.merge(right, splitKey) ; if ( logging(log) ) log(log, "-- merge: %s", page) ; this.write() ; internalCheckNodeDeep() ; if ( logging(log) ) { log(log, "<< merge: %s", this) ; log(log, "<< left: %s", left) ;
if ( logging(log) ) { log(log, ">> merge(@%d): %s", dividingSlot, this) ; log(log, ">> left: %s", left) ; BPTreePage page = left.merge(right, splitKey) ; if ( logging(log) ) log(log, "-- merge: %s", page) ; this.write() ; internalCheckNodeDeep() ; if ( logging(log) ) { log(log, "<< merge: %s", this) ; log(log, "<< left: %s", left) ;
private void split(AccessPath path, int idx, BPTreePage y) { if ( logging(log) ) { log(log, "split >> y=%s this=%s idx=%d", y.getRefStr(), this.getRefStr(), idx) ; log(log, "split -- %s", y) ; splitKey = keyRecord(splitKey) ; if ( logging(log) ) log(log, "Split key: %s", splitKey) ; if ( logging(log) ) { log(log, "Split: %s", y) ; log(log, "Split: %s", z) ; count++ ; if ( logging(log) ) { log(log, "split << %s", this) ; log(log, "split << %s", y) ;
Record rec = root.records.get(splitIdx) ; if ( logging(log) ) { log(log, "** Split root %d (%s)", splitIdx, rec) ; log(log, "splitRoot >> %s", root) ; right.count = root.maxRecords() - (splitIdx + 1) ; if ( logging(log) ) { log(log, "splitRoot -- left: %s", left) ; log(log, "splitRoot -- right: %s", right) ; root.ptrs.set(1, right.getId()) ; // slot 1 if ( logging(log) ) { log(log, "splitRoot << %s", root) ; log(log, "splitRoot << %s", left) ;