@Override protected void addTypeSpecificStats(NamedList<Object> res){
  if (statsField.includeInResponse(Stat.sum)) {
    res.add("sum",sum);
  }
  if (statsField.includeInResponse(Stat.sumOfSquares)) {
    res.add("sumOfSquares",sumOfSquares);
  }
  if (statsField.includeInResponse(Stat.mean)) {
    res.add("mean",sum / count);
  }
  if (statsField.includeInResponse(Stat.stddev)) {
    res.add("stddev",getStandardDeviation());
  }
  if (statsField.includeInResponse(Stat.percentiles)) {
    if (statsField.getIsShard()) {
      ByteBuffer buf=ByteBuffer.allocate(tdigest.byteSize());
      tdigest.asSmallBytes(buf);
      res.add("percentiles",Arrays.copyOf(buf.array(),buf.position()));
    }
 else {
      NamedList<Object> percentileNameList=new NamedList<Object>();
      for (      Double percentile : statsField.getPercentilesList()) {
        if (tdigest.size() == 0) {
          percentileNameList.add(percentile.toString(),null);
        }
 else {
          Double cutoff=tdigest.quantile(percentile / 100);
          percentileNameList.add(percentile.toString(),cutoff);
        }
      }
      res.add("percentiles",percentileNameList);
    }
  }
}

@ Override protected void addTypeSpecificStats ( NamedList < Object > res ) { if ( statsField . includeInResponse ( Stat . sum ) ) { res . add ( "sum" , sum ) ; } if ( statsField . includeInResponse ( Stat . sumOfSquares ) ) { res . add ( "sumOfSquares" , sumOfSquares ) ; } if ( statsField . includeInResponse ( Stat . mean ) ) { res . add ( "mean" , sum / count ) ; } if ( statsField . includeInResponse ( Stat . stddev ) ) { res . add ( "stddev" , getStandardDeviation ( ) ) ; } if ( statsField . includeInResponse ( Stat . percentiles ) ) { if ( statsField . getIsShard ( ) ) { ByteBuffer buf = ByteBuffer . allocate ( tdigest . byteSize ( ) ) ; tdigest . asSmallBytes ( buf ) ; res . add ( "percentiles" , Arrays . copyOf ( buf . array ( ) , buf . position ( ) ) ) ; } else { NamedList < Object > percentileNameList = new NamedList < Object > ( ) ; for ( Double percentile : statsField . getPercentilesList ( ) ) { if ( tdigest . size ( ) == 0 ) { percentileNameList . add ( percentile . toString ( ) , null ) ; } else { Double cutoff = tdigest . quantile ( percentile / 100 ) ; percentileNameList . add ( percentile . toString ( ) , cutoff ) ; } } res . add ( "percentiles" , percentileNameList ) ; } } }
adds sum , sumofsquares , mean , stddev , and percentiles to the given namedlist
