code: private static void finalizeFreshIndexStats(Map<String, OnDemandIndexStats> freshStats) {
          if (freshStats == null) {
              return;
          }
  
          for (OnDemandIndexStats freshIndexStats : freshStats.values()) {
              long totalHitCount = freshIndexStats.getTotalHitCount();
              if (totalHitCount != 0) {
                  double averageHitSelectivity = 1.0 - freshIndexStats.getAverageHitSelectivity() / totalHitCount;
                  averageHitSelectivity = Math.max(0.0, averageHitSelectivity);
                  freshIndexStats.setAverageHitSelectivity(averageHitSelectivity);
                  freshIndexStats.setAverageHitLatency(freshIndexStats.getAverageHitLatency() / totalHitCount);
              }
          }
      }
docs: Finalizes the aggregation of the freshly obtained on-demand index
  statistics by computing the final average values which are accumulated
  as total sums in {@link #aggregateFreshIndexStats}.
  
  @param freshStats the fresh stats to finalize, can be {@code null} if no
  stats was produced during the aggregation.