private static Granularity granularityFromPointsLinear(double requestedDuration, int points, long assumedIntervalMillis) {
    """
	Find the granularity in the interval that will yield a number of data points that are close to $points
	in terms of linear distance.
	
	@param requestedDuration
	@param points
	@return
    """
        int closest = Integer.MAX_VALUE;
        int diff = 0;
        Granularity gran = null;

        for (Granularity g : Granularity.granularities()) {
            if (g == Granularity.FULL)
                diff = (int)Math.abs(points - (requestedDuration / assumedIntervalMillis));
            else
                diff = (int)Math.abs(points - (requestedDuration /g.milliseconds()));
            if (diff < closest) {
                closest = diff;
                gran = g;
            } else {
                break;
            }
        }

        return gran;
    }
private static Granularity granularityFromPointsLinear(double requestedDuration, int points, long assumedIntervalMillis) {
        int closest = Integer.MAX_VALUE;
        int diff = 0;
        Granularity gran = null;

        for (Granularity g : Granularity.granularities()) {
            if (g == Granularity.FULL)
                diff = (int)Math.abs(points - (requestedDuration / assumedIntervalMillis));
            else
                diff = (int)Math.abs(points - (requestedDuration /g.milliseconds()));
            if (diff < closest) {
                closest = diff;
                gran = g;
            } else {
                break;
            }
        }

        return gran;
    }
private static Granularity granularityFromPointsLinear ( double requestedDuration , int points , long assumedIntervalMillis ) { int closest = Integer . MAX_VALUE ; int diff = 0 ; Granularity gran = null ; for ( Granularity g : Granularity . granularities ( ) ) { if ( g == Granularity . FULL ) diff = ( int ) Math . abs ( points - ( requestedDuration / assumedIntervalMillis ) ) ; else diff = ( int ) Math . abs ( points - ( requestedDuration / g . milliseconds ( ) ) ) ; if ( diff < closest ) { closest = diff ; gran = g ; } else { break ; } } return gran ; }
Find the granularity in the interval that will yield a number of data points that are close to $points
in terms of linear distance.

@param requestedDuration
@param points
@return
Find the granularity in the interval that will yield a number of data points that are close to $points in terms of linear distance .