src/main/java/org/apache/hadoop/hdfs/server/namenode/queries/TimeHistogram.java
public static Function<Long, String> computeBucketFunction(String timeRange) {
    TimeRange timeRangeEnum = TimeRange.valueOf(timeRange);
    switch (timeRangeEnum) {
      case daily:
        return time -> {
          for (Entry<String, LongRange> range : dailyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case monthly:
        return time -> {
          for (Entry<String, LongRange> range : monthlyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case yearly:
        return time -> {
          for (Entry<String, LongRange> range : yearlyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case weekly:
      default:
        return time -> {
          for (Entry<String, LongRange> range : weeklyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
    }
  }
/**
   * Function method for use by the QueryEngine to assign histogram buckets.
   *
   * @param timeRange defined time range
   * @return function mapping input time to bucket string
   */
Function method for use by the QueryEngine to assign histogram buckets.
@param timeRange defined time range
@return function mapping input time to bucket string
Function method for use by the QueryEngine to assign histogram buckets . @param timeRange defined time range @return function mapping input time to bucket string
public static Function<Long, String> computeBucketFunction(String timeRange) {
    TimeRange timeRangeEnum = TimeRange.valueOf(timeRange);
    switch (timeRangeEnum) {
      case daily:
        return time -> {
          for (Entry<String, LongRange> range : dailyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case monthly:
        return time -> {
          for (Entry<String, LongRange> range : monthlyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case yearly:
        return time -> {
          for (Entry<String, LongRange> range : yearlyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
      case weekly:
      default:
        return time -> {
          for (Entry<String, LongRange> range : weeklyRanges.entrySet()) {
            if (range.getValue().containsLong(time)) {
              return range.getKey();
            }
          }
          return "NO_MAPPING";
        };
    }
  }
public static Function < Long , String > computeBucketFunction ( String timeRange ) { TimeRange timeRangeEnum = TimeRange . valueOf ( timeRange ) ; switch ( timeRangeEnum ) { case daily : return time -> { for ( Entry < String , LongRange > range : dailyRanges . entrySet ( ) ) { if ( range . getValue ( ) . containsLong ( time ) ) { return range . getKey ( ) ; } } return "NO_MAPPING" ; } ; case monthly : return time -> { for ( Entry < String , LongRange > range : monthlyRanges . entrySet ( ) ) { if ( range . getValue ( ) . containsLong ( time ) ) { return range . getKey ( ) ; } } return "NO_MAPPING" ; } ; case yearly : return time -> { for ( Entry < String , LongRange > range : yearlyRanges . entrySet ( ) ) { if ( range . getValue ( ) . containsLong ( time ) ) { return range . getKey ( ) ; } } return "NO_MAPPING" ; } ; case weekly : default : return time -> { for ( Entry < String , LongRange > range : weeklyRanges . entrySet ( ) ) { if ( range . getValue ( ) . containsLong ( time ) ) { return range . getKey ( ) ; } } return "NO_MAPPING" ; } ; } }
Function method for use by the QueryEngine to assign histogram buckets.
Function method for use by the QueryEngine to assign histogram buckets .