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

Method openForSearch

tempodb/encoding/vparquet3/block_search.go:57–87  ·  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 // no searches currently require bloom filters or the page index. so just add them statically
64 o := []parquet.FileOption{
65 parquet.SkipBloomFilters(true),
66 parquet.SkipPageIndex(true),
67 parquet.FileReadMode(parquet.ReadModeAsync),
68 parquet.FileSchema(parquetSchema),
69 }
70
71 // if the read buffer size provided is <= 0 then we'll use the parquet default
72 readBufferSize := opts.ReadBufferSize
73 if readBufferSize <= 0 {
74 readBufferSize = parquet.DefaultFileConfig().ReadBufferSize
75 }
76
77 o = append(o, parquet.ReadBufferSize(readBufferSize))
78
79 // cached reader
80 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
81
82 _, span := tracer.Start(ctx, "parquet.OpenFile")
83 defer span.End()
84 pf, err := parquet.OpenFile(cachedReaderAt, int64(b.meta.Size_), o...)
85
86 return pf, backendReaderAt, err
87}
88
89func (b *backendBlock) Search(ctx context.Context, req *tempopb.SearchRequest, opts common.SearchOptions) (_ *tempopb.SearchResponse, err error) {
90 derivedCtx, span := tracer.Start(ctx, "parquet.backendBlock.Search",

Callers 9

FetchTagNamesMethod · 0.95
FetchTagValuesMethod · 0.95
FetchMethod · 0.95
FindTraceByIDMethod · 0.95
SearchMethod · 0.95
SearchTagsMethod · 0.95
SearchTagValuesV2Method · 0.95

Calls 3

NewBackendReaderAtFunction · 0.70
newCachedReaderAtFunction · 0.70
StartMethod · 0.65

Tested by 2