MCPcopy
hub / github.com/prometheus/prometheus / NewLeveledCompactorWithOptions

Function NewLeveledCompactorWithOptions

tsdb/compact.go:202–241  ·  view source on GitHub ↗
(ctx context.Context, r prometheus.Registerer, l *slog.Logger, ranges []int64, pool chunkenc.Pool, opts LeveledCompactorOptions)

Source from the content-addressed store, hash-verified

200}
201
202func NewLeveledCompactorWithOptions(ctx context.Context, r prometheus.Registerer, l *slog.Logger, ranges []int64, pool chunkenc.Pool, opts LeveledCompactorOptions) (*LeveledCompactor, error) {
203 if len(ranges) == 0 {
204 return nil, errors.New("at least one range must be provided")
205 }
206 if pool == nil {
207 pool = chunkenc.NewPool()
208 }
209 if l == nil {
210 l = promslog.NewNopLogger()
211 }
212 mergeFunc := opts.MergeFunc
213 if mergeFunc == nil {
214 mergeFunc = storage.NewCompactingChunkSeriesMerger(storage.ChainedSeriesMerge)
215 }
216 maxBlockChunkSegmentSize := opts.MaxBlockChunkSegmentSize
217 if maxBlockChunkSegmentSize == 0 {
218 maxBlockChunkSegmentSize = chunks.DefaultChunkSegmentSize
219 }
220 pe := opts.PE
221 if pe == nil {
222 pe = index.EncodePostingsRaw
223 }
224 if opts.Metrics == nil {
225 opts.Metrics = NewCompactorMetrics(r)
226 }
227 return &LeveledCompactor{
228 ranges: ranges,
229 chunkPool: pool,
230 logger: l,
231 metrics: opts.Metrics,
232 ctx: ctx,
233 maxBlockChunkSegmentSize: maxBlockChunkSegmentSize,
234 useUncachedIO: opts.UseUncachedIO,
235 mergeFunc: mergeFunc,
236 postingsEncoder: pe,
237 postingsDecoderFactory: opts.PD,
238 enableOverlappingCompaction: opts.EnableOverlappingCompaction,
239 blockExcludeFunc: opts.BlockExcludeFilter,
240 }, nil
241}
242
243type dirMeta struct {
244 dir string

Callers 3

TestLeveledCompactorFunction · 0.85
openFunction · 0.85
NewLeveledCompactorFunction · 0.85

Calls 3

NewPoolFunction · 0.92
NewCompactorMetricsFunction · 0.85

Tested by 1

TestLeveledCompactorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…