MCPcopy Create free account
hub / github.com/cortexproject/cortex / getBlockTimeRange

Function getBlockTimeRange

pkg/storage/parquet/util.go:8–28  ·  view source on GitHub ↗
(mint, maxt int64, timeRanges []int64)

Source from the content-addressed store, hash-verified

6}
7
8func getBlockTimeRange(mint, maxt int64, timeRanges []int64) int64 {
9 timeRange := int64(0)
10 // fallback logic to guess block time range based
11 // on MaxTime and MinTime
12 blockRange := maxt - mint
13 for _, tr := range timeRanges {
14 rangeStart := getRangeStart(mint, tr)
15 rangeEnd := rangeStart + tr
16 if tr >= blockRange && rangeEnd >= maxt {
17 timeRange = tr
18 break
19 }
20 }
21 // If the block range is too big and cannot fit any configured time range, just fallback to the final time range.
22 // This might not be accurate but should be good enough to decide if we want to convert the block to Parquet.
23 // For this to work, at least 2 block ranges are required.
24 if len(timeRanges) > 0 && timeRange == int64(0) {
25 return timeRanges[len(timeRanges)-1]
26 }
27 return timeRange
28}
29
30func getRangeStart(mint, tr int64) int64 {
31 // Compute start of aligned time range of size tr closest to the current block's start.

Callers 1

Calls 1

getRangeStartFunction · 0.70

Tested by

no test coverage detected