private static BPTreeRecords cast(BPTreePage page) { try { return (BPTreeRecords)page ; } catch (ClassCastException ex) { error("Wrong type: " + page) ; return null ; } }
private static BPTreeRecords cast(BPTreePage page) { try { return (BPTreeRecords)page ; } catch (ClassCastException ex) { error("Wrong type: " + page) ; return null ; } }
@Override public final void checkNode() { if ( !CheckingNode ) return ; if ( rBuff.size() < 0 || rBuff.size() > rBuff.maxSize() ) error("Misized: %s", this) ; for ( int i = 1 ; i < getCount() ; i++ ) { Record r1 = rBuff.get(i - 1) ; Record r2 = rBuff.get(i) ; if ( Record.keyGT(r1, r2) ) error("Not sorted: %s", this) ; } }
@Override public final void checkNode() { if ( !CheckingNode ) return ; if ( rBuff.size() < 0 || rBuff.size() > rBuff.maxSize() ) error("Misized: %s", this) ; for ( int i = 1 ; i < getCount() ; i++ ) { Record r1 = rBuff.get(i - 1) ; Record r2 = rBuff.get(i) ; if ( Record.keyGT(r1, r2) ) error("Not sorted: %s", this) ; } }
/** * Split: place old high half in 'other'. Return the new (upper) * BPTreeRecords(BPTreePage). * Split is the high end of the low page. */ @Override public BPTreePage split() { BPTreeRecords other = insertNewPage() ; int splitIdx = rBuff.size() / 2 - 1 ; Record r = rBuff.get(splitIdx) ; // Only need key for checking later. int moveLen = rBuff.size() - (splitIdx + 1) ; // Number to move. // Copy high end to new. rBuff.copy(splitIdx + 1, other.getRecordBufferPage().getRecordBuffer(), 0, moveLen) ; rBuff.clear(splitIdx + 1, moveLen) ; rBuff.setSize(splitIdx + 1) ; if ( CheckingNode ) { if ( !Record.keyEQ(r, maxRecord()) ) { System.err.println(rBuff) ; System.err.println(other.rBuff) ; error("BPTreeRecords.split: Not returning expected record") ; } } return other ; }
/** * Split: place old high half in 'other'. Return the new (upper) * BPTreeRecords(BPTreePage). * Split is the high end of the low page. */ @Override public BPTreePage split() { BPTreeRecords other = insertNewPage() ; int splitIdx = rBuff.size() / 2 - 1 ; Record r = rBuff.get(splitIdx) ; // Only need key for checking later. int moveLen = rBuff.size() - (splitIdx + 1) ; // Number to move. // Copy high end to new. rBuff.copy(splitIdx + 1, other.getRecordBufferPage().getRecordBuffer(), 0, moveLen) ; rBuff.clear(splitIdx + 1, moveLen) ; rBuff.setSize(splitIdx + 1) ; if ( CheckingNode ) { if ( !Record.keyEQ(r, maxRecord()) ) { System.err.println(rBuff) ; System.err.println(other.rBuff) ; error("BPTreeRecords.split: Not returning expected record") ; } } return other ; }