private void ensureRoom ( int nextBuildKeyPosition ) { if ( nextBuildKeyPosition < MAX_KEYS ) return ; // flush even number of items so we don't waste leaf space repeatedly Object [ ] flushUp = buildFromRange ( 0 , FAN_FACTOR , isLeaf ( copyFrom ) , true ) ; ensureParent ( ) . addExtraChild ( flushUp , buildKeys [ FAN_FACTOR ] ) ; int size = FAN_FACTOR + 1 ; assert size <= buildKeyPosition : buildKeyPosition + "," + nextBuildKeyPosition ; System . arraycopy ( buildKeys , size , buildKeys , 0 , buildKeyPosition - size ) ; buildKeyPosition -= size ; maxBuildKeyPosition = buildKeys . length ; if ( buildChildPosition > 0 ) { System . arraycopy ( buildChildren , size , buildChildren , 0 , buildChildPosition - size ) ; buildChildPosition -= size ; } }
checks if we can add the requested keys + children to the builder and if not we spill - over into our parent