pickSchema returns the largest number n between -4 and 8 such that 2^(2^-n) is less or equal the provided bucketFactor. Special cases: - bucketFactor <= 1: panics. - bucketFactor < 2^(2^-8) (but > 1): still returns 8.
(bucketFactor float64)
| 1460 | // - bucketFactor <= 1: panics. |
| 1461 | // - bucketFactor < 2^(2^-8) (but > 1): still returns 8. |
| 1462 | func pickSchema(bucketFactor float64) int32 { |
| 1463 | if bucketFactor <= 1 { |
| 1464 | panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor)) |
| 1465 | } |
| 1466 | floor := math.Floor(math.Log2(math.Log2(bucketFactor))) |
| 1467 | switch { |
| 1468 | case floor <= -8: |
| 1469 | return nativeHistogramSchemaMaximum |
| 1470 | case floor >= 4: |
| 1471 | return nativeHistogramSchemaMinimum |
| 1472 | default: |
| 1473 | return -int32(floor) |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) { |
| 1478 | var ii []int |