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

Method file

tempodb/encoding/vparquet5/wal_block.go:226–259  ·  view source on GitHub ↗

file() opens the parquet file and returns it. previously this method cached the file on first open but the memory cost of this was quite high. so instead we open it fresh every time. This also allows it to take the context for the caller.

(ctx context.Context)

Source from the content-addressed store, hash-verified

224// but the memory cost of this was quite high. so instead we open it fresh every time. This
225// also allows it to take the context for the caller.
226func (w *walBlockFlush) file(ctx context.Context) (*pageFile, error) {
227 if err := ctx.Err(); err != nil {
228 return nil, err
229 }
230
231 file, err := os.OpenFile(w.path, os.O_RDONLY, 0o600)
232 if err != nil {
233 return nil, fmt.Errorf("error opening file: %w", err)
234 }
235 info, err := file.Stat()
236 if err != nil {
237 return nil, fmt.Errorf("error getting file info: %w", err)
238 }
239 size := info.Size()
240
241 sch, _, _ := SchemaWithDynamicChanges(w.dedcols)
242
243 wr := newWalReaderAt(ctx, file)
244 o := []parquet.FileOption{
245 parquet.SkipBloomFilters(true),
246 parquet.SkipPageIndex(true),
247 parquet.FileSchema(sch),
248 parquet.FileReadMode(parquet.ReadModeAsync),
249 }
250
251 pf, err := parquet.OpenFile(wr, size, o...)
252 if err != nil {
253 return nil, fmt.Errorf("error opening parquet file: %w", err)
254 }
255
256 f := &pageFile{parquetFile: pf, osFile: file, r: wr}
257
258 return f, nil
259}
260
261func (w *walBlockFlush) rowIterator(ctx context.Context) (*rowIterator, error) {
262 file, err := w.file(ctx)

Callers 10

rowIteratorMethod · 0.95
openWALBlockFunction · 0.45
FindTraceByIDMethod · 0.45
SearchMethod · 0.45
SearchTagsMethod · 0.45
SearchTagValuesV2Method · 0.45
FetchMethod · 0.45
FetchSpansMethod · 0.45
FetchTagValuesMethod · 0.45
FetchTagNamesMethod · 0.45

Calls 3

SchemaWithDynamicChangesFunction · 0.85
newWalReaderAtFunction · 0.70
SizeMethod · 0.65

Tested by

no test coverage detected