private int chooseSplitAxis(IntIterator dimensionIterator, int minEntries, int maxEntries) {
    // assert that there ARE dimensions to be tested
    if(!dimensionIterator.hasNext()) {
      return -1;
    }

    int numOfEntries = node.getNumEntries();

    assert minEntries >= 1 && minEntries <= maxEntries && maxEntries <= numOfEntries;

    double optSurfaceSum = Double.POSITIVE_INFINITY;
    int optAxis = -1;

    int[] entriesByLB = new int[node.getNumEntries()];
    for(int i = 0; i < entriesByLB.length; i++) {
      entriesByLB[i] = i;
    }
    int[] entriesByUB = Arrays.copyOf(entriesByLB, node.getNumEntries());

    int[] entriesByLBRev = null, entriesByUBRev = null;
    if(maxEntries <= node.getNumEntries() / 2) {
      System.out.println("THIS HAPPENS!!");
      // initialize backwards direction
      entriesByLBRev = new int[node.getNumEntries()];
      entriesByUBRev = new int[node.getNumEntries()];
    }

    while(dimensionIterator.hasNext()) {
      int d = dimensionIterator.nextInt();
      sortEntriesForDimension(d, entriesByLB, entriesByUB);
      double surfaceSum = generateDistributionsAndSurfaceSums(minEntries, maxEntries, entriesByLB, entriesByUB);
      if(maxEntries <= node.getNumEntries() / 2) { // add opposite ranges
        System.out.println("THIS HAPPENS intern");
        for(int j = 0; j < entriesByUB.length; j++) {
          // reverse sorting
          entriesByUBRev[node.getNumEntries() - 1 - j] = entriesByUB[j];
          entriesByLBRev[node.getNumEntries() - 1 - j] = entriesByLB[j];
        }
        surfaceSum += generateDistributionsAndSurfaceSums(minEntries, maxEntries, entriesByLBRev, entriesByUBRev);
      }
      if(surfaceSum < optSurfaceSum) {
        optSurfaceSum = surfaceSum;
        optAxis = d;
      }
    }
    // file the split axis
    this.splitAxis = optAxis;
    return optAxis;
  }
private int chooseSplitAxis ( IntIterator dimensionIterator , int minEntries , int maxEntries ) { if ( ! dimensionIterator . hasNext ( ) ) { return - 1 ; } int numOfEntries = node . getNumEntries ( ) ; assert minEntries >= 1 && minEntries <= maxEntries && maxEntries <= numOfEntries ; double optSurfaceSum = Double . POSITIVE_INFINITY ; int optAxis = - 1 ; int [ ] entriesByLB = new int [ node . getNumEntries ( ) ] ; for ( int i = 0 ; i < entriesByLB . length ; i ++ ) { entriesByLB [ i ] = i ; } int [ ] entriesByUB = Arrays . copyOf ( entriesByLB , node . getNumEntries ( ) ) ; int [ ] entriesByLBRev = null , entriesByUBRev = null ; if ( maxEntries <= node . getNumEntries ( ) / 2 ) { System . out . println ( "THIS HAPPENS!!" ) ; entriesByLBRev = new int [ node . getNumEntries ( ) ] ; entriesByUBRev = new int [ node . getNumEntries ( ) ] ; } while ( dimensionIterator . hasNext ( ) ) { int d = dimensionIterator . nextInt ( ) ; sortEntriesForDimension ( d , entriesByLB , entriesByUB ) ; double surfaceSum = generateDistributionsAndSurfaceSums ( minEntries , maxEntries , entriesByLB , entriesByUB ) ; if ( maxEntries <= node . getNumEntries ( ) / 2 ) { System . out . println ( "THIS HAPPENS intern" ) ; for ( int j = 0 ; j < entriesByUB . length ; j ++ ) { entriesByUBRev [ node . getNumEntries ( ) - 1 - j ] = entriesByUB [ j ] ; entriesByLBRev [ node . getNumEntries ( ) - 1 - j ] = entriesByLB [ j ] ; } surfaceSum += generateDistributionsAndSurfaceSums ( minEntries , maxEntries , entriesByLBRev , entriesByUBRev ) ; } if ( surfaceSum < optSurfaceSum ) { optSurfaceSum = surfaceSum ; optAxis = d ; } } this . splitAxis = optAxis ; return optAxis ; }
Get the dimension with the minimum surface sum.
<p>
This is done by calculating every possible split in each given dimension
and the sum of surfaces of all splits for every dimension.

@param dimensionIterator The dimensions that should be tested
@param minEntries Minimum number of entries in each sub group; in case of a
data node, this is the minimum leaf capacity, for directory nodes,
this is either the minimum directory capacity or, if a topological
split has already failed, the tree's minimum fan-out parameter.
@param maxEntries Maximum number of entries in each sub group
@return The dimension with the minimum surface sum, or <code>null</code> if
dimensionIterable yielded nothing