openForSearch consolidates all the logic for opening a parquet file
(ctx context.Context, opts common.SearchOptions)
| 55 | |
| 56 | // openForSearch consolidates all the logic for opening a parquet file |
| 57 | func (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 | |
| 89 | func (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", |