MCPcopy
hub / github.com/grafana/tempo / openForSearch

Method openForSearch

tempodb/encoding/vparquet5/block_search.go:57–90  ·  view source on GitHub ↗

openForSearch consolidates all the logic for opening a parquet file

(ctx context.Context, opts common.SearchOptions)

Source from the content-addressed store, hash-verified

55
56// openForSearch consolidates all the logic for opening a parquet file
57func (b *backendBlock) openForSearch(ctx context.Context, opts common.SearchOptions) (*parquet.File, *BackendReaderAt, error) {
58 b.openMtx.Lock()
59 defer b.openMtx.Unlock()
60
61 // TODO: ctx is also cached when we cache backendReaderAt, not ideal but leaving it as is for now
62 backendReaderAt := NewBackendReaderAt(ctx, b.r, DataFileName, b.meta)
63
64 schema, _, _ := SchemaWithDynamicChanges(b.meta.DedicatedColumns)
65
66 // no searches currently require bloom filters or the page index. so just add them statically
67 o := []parquet.FileOption{
68 parquet.SkipBloomFilters(true),
69 parquet.SkipPageIndex(true),
70 parquet.FileReadMode(parquet.ReadModeAsync),
71 parquet.FileSchema(schema),
72 }
73
74 // if the read buffer size provided is <= 0 then we'll use the parquet default
75 readBufferSize := opts.ReadBufferSize
76 if readBufferSize <= 0 {
77 readBufferSize = parquet.DefaultFileConfig().ReadBufferSize
78 }
79
80 o = append(o, parquet.ReadBufferSize(readBufferSize))
81
82 // cached reader
83 cachedReaderAt := newCachedReaderAt(backendReaderAt, readBufferSize, int64(b.meta.Size_), b.meta.FooterSize) // most reads to the backend are going to be readbuffersize so use it as our "page cache" size
84
85 _, span := tracer.Start(ctx, "parquet.OpenFile")
86 defer span.End()
87 pf, err := parquet.OpenFile(cachedReaderAt, int64(b.meta.Size_), o...)
88
89 return pf, backendReaderAt, err
90}
91
92func (b *backendBlock) Search(ctx context.Context, req *tempopb.SearchRequest, opts common.SearchOptions) (_ *tempopb.SearchResponse, err error) {
93 derivedCtx, span := tracer.Start(ctx, "parquet.backendBlock.Search",

Callers 12

FetchTagNamesMethod · 0.95
FetchTagValuesMethod · 0.95
FetchMethod · 0.95
FindTraceByIDMethod · 0.95
FetchSpansMethod · 0.95
SearchMethod · 0.95
SearchTagsMethod · 0.95
SearchTagValuesV2Method · 0.95
BenchmarkIteratorsFunction · 0.45
BenchmarkReadSingleTraceFunction · 0.45
TestSamplingErrorFunction · 0.45

Calls 4

SchemaWithDynamicChangesFunction · 0.85
NewBackendReaderAtFunction · 0.70
newCachedReaderAtFunction · 0.70
StartMethod · 0.65

Tested by 4

BenchmarkIteratorsFunction · 0.36
BenchmarkReadSingleTraceFunction · 0.36
TestSamplingErrorFunction · 0.36