public IndexSegmentPlan(final int m,final long nentries){
  if (m < Options.MIN_BRANCHING_FACTOR)   throw new IllegalArgumentException();
  if (nentries < 0)   throw new IllegalArgumentException();
  this.m=m;
  this.nentries=nentries;
  m2=(m + 1) / 2;
  if (nentries == 0) {
    if (log.isInfoEnabled())     log.info("Empty tree.");
    nleaves=1;
    height=0;
    numInLeaf=new int[]{0};
    numInNode=new int[][]{new int[]{0}};
    numInLevel=new long[]{1};
    nnodes=0;
    return;
  }
  nleaves=(int)Math.ceil((double)nentries / (double)m);
  height=getMinimumHeight(m,nleaves);
  if (log.isInfoEnabled())   log.info("branchingFactor=" + m + ", nentries="+ nentries+ ", nleaves="+ nleaves+ ", height="+ height);
  numInLeaf=distributeKeys(m,m2,nleaves,nentries);
  numInNode=new int[height + 1][];
  numInLevel=new long[height + 1];
  long nchildren=nleaves;
  int nnodes=0;
  for (int h=height - 1; h >= 0; h--) {
    final long numThisLevel=(long)Math.ceil((double)nchildren / (double)m);
    numInLevel[h]=numThisLevel;
    numInNode[h]=distributeChildren(m,m2,numThisLevel,nchildren);
    nchildren=numThisLevel;
    nnodes+=numThisLevel;
  }
  numInNode[height]=numInLeaf;
  numInLevel[height]=nleaves;
  this.nnodes=nnodes;
}

public IndexSegmentPlan ( final int m , final long nentries ) { if ( m < Options . MIN_BRANCHING_FACTOR ) throw new IllegalArgumentException ( ) ; if ( nentries < 0 ) throw new IllegalArgumentException ( ) ; this . m = m ; this . nentries = nentries ; m2 = ( m + 1 ) / 2 ; if ( nentries == 0 ) { if ( log . isInfoEnabled ( ) ) log . info ( "Empty tree." ) ; nleaves = 1 ; height = 0 ; numInLeaf = new int [ ] { 0 } ; numInNode = new int [ ] [ ] { new int [ ] { 0 } } ; numInLevel = new long [ ] { 1 } ; nnodes = 0 ; return ; } nleaves = ( int ) Math . ceil ( ( double ) nentries / ( double ) m ) ; height = getMinimumHeight ( m , nleaves ) ; if ( log . isInfoEnabled ( ) ) log . info ( "branchingFactor=" + m + ", nentries=" + nentries + ", nleaves=" + nleaves + ", height=" + height ) ; numInLeaf = distributeKeys ( m , m2 , nleaves , nentries ) ; numInNode = new int [ height + 1 ] [ ] ; numInLevel = new long [ height + 1 ] ; long nchildren = nleaves ; int nnodes = 0 ; for ( int h = height - 1 ; h >= 0 ; h -- ) { final long numThisLevel = ( long ) Math . ceil ( ( double ) nchildren / ( double ) m ) ; numInLevel [ h ] = numThisLevel ; numInNode [ h ] = distributeChildren ( m , m2 , numThisLevel , nchildren ) ; nchildren = numThisLevel ; nnodes += numThisLevel ; } numInNode [ height ] = numInLeaf ; numInLevel [ height ] = nleaves ; this . nnodes = nnodes ; }
create a plan for building a b + - tree . the plan has only these two inputs . everything else about the plan is deterministic based on those values .
