code: func (hg *Histogram) PreCalculateScalar() {
  	len := hg.Len()
  	if len == 0 {
  		return
  	}
  	switch hg.GetLower(0).Kind() {
  	case types.KindMysqlDecimal, types.KindMysqlTime:
  		hg.scalars = make([]scalar, len)
  		for i := 0; i < len; i++ {
  			hg.scalars[i] = scalar{
  				lower: convertDatumToScalar(hg.GetLower(i), 0),
  				upper: convertDatumToScalar(hg.GetUpper(i), 0),
  			}
  		}
  	case types.KindBytes, types.KindString:
  		hg.scalars = make([]scalar, len)
  		for i := 0; i < len; i++ {
  			lower, upper := hg.GetLower(i), hg.GetUpper(i)
  			common := commonPrefixLength(lower.GetBytes(), upper.GetBytes())
  			hg.scalars[i] = scalar{
  				commonPfxLen: common,
  				lower:        convertDatumToScalar(lower, common),
  				upper:        convertDatumToScalar(upper, common),
  			}
  		}
  	}
  }
docs: // PreCalculateScalar converts the lower and upper to scalar. When the datum type is KindString or KindBytes, we also
  // calculate their common prefix length, because when a value falls between lower and upper, the common prefix
  // of lower and upper equals to the common prefix of the lower, upper and the value. For some simple types like `Int64`,
  // we do not convert it because we can directly infer the scalar value.