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

Method Validate

tempodb/encoding/vparquet4/block.go:46–79  ·  view source on GitHub ↗

Validate will do a basic sanity check of the state of the parquet file. This can be extended to do more checks in the future. This method should lean towards being cost effective over complete.

(ctx context.Context)

Source from the content-addressed store, hash-verified

44// Validate will do a basic sanity check of the state of the parquet file. This can be extended to do more checks in the future.
45// This method should lean towards being cost effective over complete.
46func (b *backendBlock) Validate(ctx context.Context) error {
47 if b.meta == nil {
48 return errors.New("block meta is nil")
49 }
50
51 // read last 8 bytes of the file to confirm its at least complete. the last 4 should be ascii "PAR1"
52 // and the 4 bytes before that should be the length of the footer
53 buff := make([]byte, 8)
54 err := b.r.ReadRange(ctx, DataFileName, uuid.UUID(b.meta.BlockID), b.meta.TenantID, b.meta.Size_-8, buff, nil)
55 if err != nil {
56 return fmt.Errorf("failed to read parquet magic footer: %w", err)
57 }
58
59 if string(buff[4:]) != "PAR1" {
60 return fmt.Errorf("invalid parquet magic footer: %x", buff[4:])
61 }
62
63 footerSize := int64(binary.LittleEndian.Uint32(buff[:4]))
64 if footerSize != int64(b.meta.FooterSize) {
65 return fmt.Errorf("unexpected parquet footer size: %d", footerSize)
66 }
67
68 // read the first byte from all blooms to confirm they exist
69 buff = make([]byte, 1)
70 for i := 0; i < int(b.meta.BloomShardCount); i++ {
71 bloomName := common.BloomName(i)
72 err = b.r.ReadRange(ctx, bloomName, uuid.UUID(b.meta.BlockID), b.meta.TenantID, 0, buff, nil)
73 if err != nil {
74 return fmt.Errorf("failed to read first byte of bloom(%d): %w", i, err)
75 }
76 }
77
78 return nil
79}
80
81func (b *backendBlock) FetchSpans(_ context.Context, _ traceql.FetchSpansRequest, _ common.SearchOptions) (traceql.FetchSpansOnlyResponse, error) {
82 return traceql.FetchSpansOnlyResponse{}, util.ErrUnsupported

Callers

nothing calls this directly

Calls 2

BloomNameFunction · 0.92
ReadRangeMethod · 0.65

Tested by

no test coverage detected