code: public VectorApproximation calculateApproximation(DBID id, V dv) {
      int[] approximation = new int[dv.getDimensionality()];
      for(int d = 0; d < splitPositions.length; d++) {
        final double val = dv.doubleValue(d);
        final int lastBorderIndex = splitPositions[d].length - 1;
  
        // Value is below data grid
        if(val < splitPositions[d][0]) {
          approximation[d] = 0;
          if(id != null) {
            LOG.warning("Vector outside of VAFile grid!");
          }
        } // Value is above data grid
        else if(val > splitPositions[d][lastBorderIndex]) {
          approximation[d] = lastBorderIndex - 1;
          if(id != null) {
            LOG.warning("Vector outside of VAFile grid!");
          }
        } // normal case
        else {
          // Search grid position
          int pos = Arrays.binarySearch(splitPositions[d], val);
          pos = (pos >= 0) ? pos : ((-pos) - 2);
          approximation[d] = pos;
        }
      }
      return new VectorApproximation(id, approximation);
    }
docs: Calculate the VA file position given the existing borders.
  
  @param id Object ID
  @param dv Data vector
  @return Vector approximation